[
https://issues.apache.org/jira/browse/CASSANDRA-16307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17277441#comment-17277441
]
Andres de la Peña commented on CASSANDRA-16307:
-----------------------------------------------
That's a nice finding! However I think that it only solves some of the problems
with paging and {{GROUP BY}}. The test above was an attempt to simplify [the
original
tests|https://github.com/apache/cassandra/blob/16075ed5c7429b3dd30d1e894b20e3598b8b9a10/test/distributed/org/apache/cassandra/distributed/test/ShortReadProtectionTest.java#L301-L347]
in CASSANDRA-16180 where we found the problem. I'm afraid that a test more
faithful to the original still fails:
{code:java}
try (Cluster cluster = init(Cluster.create(2)))
{
cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (pk int, ck int,
PRIMARY KEY (pk, ck))"));
cluster.get(1).executeInternal(withKeyspace("INSERT INTO %s.t (pk, ck)
VALUES (1, 1) USING TIMESTAMP 0"));
cluster.get(1).executeInternal(withKeyspace("DELETE FROM %s.t WHERE pk=0
AND ck=0"));
cluster.get(1).executeInternal(withKeyspace("INSERT INTO %s.t (pk, ck)
VALUES (2, 2) USING TIMESTAMP 0"));
cluster.get(2).executeInternal(withKeyspace("DELETE FROM %s.t WHERE pk=1
AND ck=1"));
cluster.get(2).executeInternal(withKeyspace("INSERT INTO %s.t (pk, ck)
VALUES (0, 0) USING TIMESTAMP 0"));
cluster.get(2).executeInternal(withKeyspace("DELETE FROM %s.t WHERE pk=2
AND ck=2"));
String query = withKeyspace("SELECT * FROM %s.t GROUP BY pk");
Iterator<Object[]> rows = cluster.coordinator(1).executeWithPaging(query,
ConsistencyLevel.ALL, 1);
assertRows(Iterators.toArray(rows, Object[].class));
}
{code}
Apparently this can also be reproduced with a Python dtest, suggesting that the
problem is not only caused by in-jvm dtests:
{code:python}
cluster = self.cluster
cluster.populate(2).start()
node1, node2 = cluster.nodelist()
session = self.patient_exclusive_cql_connection(node1,
consistency_level=ConsistencyLevel.ONE)
create_ks(session, 'ks', 2)
session.execute('CREATE TABLE ks.t (pk int, ck int, PRIMARY KEY (pk, ck))')
node2.stop()
session.execute('INSERT INTO ks.t (pk, ck) VALUES (1, 1) USING TIMESTAMP 0')
session.execute('DELETE FROM ks.t WHERE pk=0 AND ck=0')
session.execute('INSERT INTO ks.t (pk, ck) VALUES (2, 2) USING TIMESTAMP 0')
node2.start()
node1.stop()
session = self.patient_exclusive_cql_connection(node2,
consistency_level=ConsistencyLevel.ONE)
session.execute('DELETE FROM ks.t WHERE pk=1 AND ck=1')
session.execute('INSERT INTO ks.t (pk, ck) VALUES (0, 0) USING TIMESTAMP 0')
session.execute('DELETE FROM ks.t WHERE pk=2 AND ck=2')
node1.start()
session = self.patient_exclusive_cql_connection(node1,
consistency_level=ConsistencyLevel.ALL)
session.default_fetch_size = 1
assert_none(session, 'SELECT * FROM ks.t GROUP BY pk')
{code}
> GROUP BY queries with paging can return deleted data
> ----------------------------------------------------
>
> Key: CASSANDRA-16307
> URL: https://issues.apache.org/jira/browse/CASSANDRA-16307
> Project: Cassandra
> Issue Type: Bug
> Components: Consistency/Coordination
> Reporter: Andres de la Peña
> Assignee: Alex Petrov
> Priority: Normal
> Fix For: 3.11.x, 4.0-beta
>
>
> {{GROUP BY}} queries using paging and CL>ONE/LOCAL_ONE. This dtest reproduces
> the problem:
> {code:java}
> try (Cluster cluster = init(Cluster.create(2)))
> {
> cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (pk int, ck int,
> PRIMARY KEY (pk, ck))"));
> ICoordinator coordinator = cluster.coordinator(1);
> coordinator.execute(withKeyspace("INSERT INTO %s.t (pk, ck) VALUES (0,
> 0)"), ConsistencyLevel.ALL);
> coordinator.execute(withKeyspace("INSERT INTO %s.t (pk, ck) VALUES (1,
> 1)"), ConsistencyLevel.ALL);
>
> cluster.get(1).executeInternal(withKeyspace("DELETE FROM %s.t WHERE pk=0
> AND ck=0"));
> cluster.get(2).executeInternal(withKeyspace("DELETE FROM %s.t WHERE pk=1
> AND ck=1"));
> String query = withKeyspace("SELECT * FROM %s.t GROUP BY pk");
> Iterator<Object[]> rows = coordinator.executeWithPaging(query,
> ConsistencyLevel.ALL, 1);
> assertRows(Iterators.toArray(rows, Object[].class));
> }
> {code}
> Using a 2-node cluster and RF=2, the test inserts two partitions in both
> nodes. Then it locally deletes each row in a separate node, so each node sees
> a different partition alive, but reconciliation should produce no alive
> partitions. However, a {{GROUP BY}} query using a page size of 1 wrongly
> returns one of the rows.
> This has been detected during CASSANDRA-16180, and it is probably related to
> CASSANDRA-15459, which solved a similar problem for group-by queries with
> limit, instead of paging.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]