Marcus Eriksson created CASSANDRA-20972:
-------------------------------------------

             Summary: DISTINCT queries failing with range tombstones
                 Key: CASSANDRA-20972
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20972
             Project: Apache Cassandra
          Issue Type: Bug
          Components: Local/SSTable
            Reporter: Marcus Eriksson
            Assignee: Marcus Eriksson


Queries like {{select distinct id from %s.tbl where token(id) > 0}} fail if 
there is an overlapping range tombstone:
{code}
ERROR 10:35:30 Exception in thread Thread[node1_ReadStage-1,5,SharedPool]
java.lang.RuntimeException: java.lang.IllegalStateException: The 
UnfilteredRowIterator returned by the last call to next() was initialized: it 
must be closed before calling hasNext() or next() again.
        at 
org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2612)
        at 
org.apache.cassandra.concurrent.ExecutionFailure$2.run(ExecutionFailure.java:163)
        at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:143)
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: The UnfilteredRowIterator returned 
by the last call to next() was initialized: it must be closed before calling 
hasNext() or next() again.
        at 
org.apache.cassandra.io.sstable.format.SSTableScanner$BaseKeyScanningIterator.computeNext(SSTableScanner.java:241)
        at 
org.apache.cassandra.io.sstable.format.SSTableScanner$BaseKeyScanningIterator.computeNext(SSTableScanner.java:228)
        at 
org.apache.cassandra.utils.AbstractIterator.hasNext(AbstractIterator.java:47)
        at 
org.apache.cassandra.io.sstable.format.SSTableScanner.hasNext(SSTableScanner.java:190)
        at 
org.apache.cassandra.db.transform.BasePartitions.hasNext(BasePartitions.java:90)
        at 
org.apache.cassandra.utils.MergeIterator$Candidate.advance(MergeIterator.java:375)
        at 
org.apache.cassandra.utils.MergeIterator$ManyToOne.advance(MergeIterator.java:187)
        at 
org.apache.cassandra.utils.MergeIterator$ManyToOne.computeNext(MergeIterator.java:156)
{code}

Reason is that when {{LazilyInitializedUnfilteredRowIterator}} is closed the 
underlying iterator is nulled out, this allows the iterator to be 
re-initialized if anyone accesses a method that calls {{maybeInit}}, like 
{{isReverseOrder()}} which is called when adding an artificial range tombstone 
bound closer.

This was caused by CASSANDRA-18398



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to