[
https://issues.apache.org/jira/browse/CASSANDRA-6447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylvain Lebresne updated CASSANDRA-6447:
----------------------------------------
Attachment: 6447.txt
I believe the fix is a tiny bit less trivial than that. If the first row in
discardFirst has no live data, we need to check the following rows until we
find one to discard, otherwise paging would end up return twice the same
result. Not sure why discardFirst is not handling that correctly since
discardLast is, but anyway, attaching patch to fix (the patch also slightly
modify discardLast because it was actually not handling the case where there
was less live rows than we want to discard).
> SELECT someColumns FROM table results in AssertionError in
> AbstractQueryPager.discardFirst
> ------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-6447
> URL: https://issues.apache.org/jira/browse/CASSANDRA-6447
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Environment: Cluster: single node server (ubuntu)
> Cassandra version: 2.0.3 (server/client)
> Client: Datastax cassandra-driver-core 2.0.0-rc1
> Reporter: Julien Aymé
> Assignee: Julien Aymé
> Fix For: 2.0.4
>
> Attachments: 6447.txt, cassandra-2.0-6447.patch, stacktrace.txt
>
>
> I have a query which must read all the rows from the table:
> Query: "SELECT key, col1, col2, col3 FROM mytable"
> Here is the corresponding code (this is using datastax driver):
> {code}
> ResultSet result = session.execute("SELECT key, col1, col2, col3 FROM
> mytable");
> for (Row row : result) {
> // do some work with row
> }
> {code}
> Messages sent from the client to Cassandra:
> * 1st: {{QUERY SELECT key, col1, col2, col3 FROM mytable([cl=ONE, vals=[],
> skip=false, psize=5000, state=null, serialCl=ONE])}}
> * 2nd: {{QUERY SELECT key, col1, col2, col3 FROM mytable([cl=ONE, vals=[],
> skip=false, psize=5000, state=java.nio.HeapByteBuffer[pos=24 lim=80
> cap=410474], serialCl=ONE])}}
> On the first message, everything is fine, and the server returns 5000 rows.
> On the second message, paging is in progress, and the server fails in
> AbstractQueryPager.discardFirst: AssertionError (stack trace attached).
> Here is some more info (step by step debugging on reception of 2nd message):
> {code}
> AbstractQueryPager.fetchPage(int):
> * pageSize=5000, currentPageSize=5001, rows size=5002, liveCount=5001
> * containsPreviousLast(rows.get(0)) returns true
> -> AbstractQueryPager.discardFirst(List<Row>):
> * rows size=5002
> * first=TreeMapBackedSortedColumns[with TreeMap size=1]
> -> AbstractQueryPager.discardHead(ColumnFamily, ...):
> * counter = ColumnCounter$GroupByPrefix
> * iter.hasNext() returns true (TreeMap$ValueIterator with TreeMap size=1)
> * Column c = DeletedColumn
> * counter.count() -> c.isLive returns false (c is DeletedColumn)
> * counter.live() = 0
> * iter.hasNext() returns false
> * Math.min(0, toDiscard==1) returns 0
> <- AbstractQueryPager.discardFirst(List<Row>):
> * discarded = 0;
> * count = newCf.getColumnCount() = 0;
> {code}
> -> assert discarded == 1 *throws AssertionError*
--
This message was sent by Atlassian JIRA
(v6.1.4#6159)