[
https://issues.apache.org/jira/browse/CASSANDRA-16241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17228891#comment-17228891
]
Yifan Cai commented on CASSANDRA-16241:
---------------------------------------
Beside leaving clustering key empty on insertion, there is one other case that
generates null values in clustering key.
When dropping the {{COMPACT STORAGE}} from a table that has no clustering
columns, a new clustering column is added to the table, and its value could be
null. I modified your test to simulate that scenario, but compaction does not
have a problem with it (using trunk code base).
The patch makes sense to me. +1 and thanks.
> ArrayClustering does not properly handle null clustering key elements left
> over from tables created WITH COMPACT STORAGE
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-16241
> URL: https://issues.apache.org/jira/browse/CASSANDRA-16241
> Project: Cassandra
> Issue Type: Bug
> Components: Local/Compaction
> Reporter: Caleb Rackliffe
> Assignee: Caleb Rackliffe
> Priority: Normal
> Labels: compaction
> Fix For: 4.0-beta
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The only way we can produce null clustering key elements is leaving them
> empty on insert while a table is still compact. If we subsequently DROP
> COMPACT STORAGE, those null elements linger, and {{ArrayClustering}} does not
> handle them appropriately on compaction.
> If you run the test
> [here|https://github.com/maedhroz/cassandra/commit/e247b7868cae383168153bbe8bbbaa47a660f76b],
> you should be able to observe an exception that looks roughly like this:
> {noformat}
> java.lang.NullPointerException
> at java.base/java.nio.ByteBuffer.wrap(ByteBuffer.java:422)
> at
> org.apache.cassandra.db.AbstractArrayClusteringPrefix.getBufferArray(AbstractArrayClusteringPrefix.java:45)
> at
> org.apache.cassandra.io.sstable.metadata.MetadataCollector.finalizeMetadata(MetadataCollector.java:246)
> at
> org.apache.cassandra.io.sstable.format.SSTableWriter.finalizeMetadata(SSTableWriter.java:315)
> at
> org.apache.cassandra.io.sstable.format.big.BigTableWriter.access$200(BigTableWriter.java:52)
> at
> org.apache.cassandra.io.sstable.format.big.BigTableWriter$TransactionalProxy.doPrepare(BigTableWriter.java:415)
> at
> org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.prepareToCommit(Transactional.java:168)
> at
> org.apache.cassandra.io.sstable.format.SSTableWriter.prepareToCommit(SSTableWriter.java:283)
> at
> org.apache.cassandra.io.sstable.SSTableRewriter.doPrepare(SSTableRewriter.java:380)
> at
> org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.prepareToCommit(Transactional.java:168)
> at
> org.apache.cassandra.db.compaction.writers.CompactionAwareWriter.doPrepare(CompactionAwareWriter.java:118)
> at
> org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.prepareToCommit(Transactional.java:168)
> at
> org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.finish(Transactional.java:179)
> at
> org.apache.cassandra.db.compaction.writers.CompactionAwareWriter.finish(CompactionAwareWriter.java:128)
> at
> org.apache.cassandra.db.compaction.CompactionTask.runMayThrow(CompactionTask.java:225)
> at
> org.apache.cassandra.utils.WrappedRunnable.run(WrappedRunnable.java:28)
> {noformat}
> There are already numerous places where we respect the fact that clustering
> elements may be null, so this should be pretty straightforward to fix, and
> the tests that accompany it will probably be more complex than the fix itself.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]