Kristijonas Zalys created CASSANDRA-21731:
---------------------------------------------

             Summary: Fix IndexedEntry skipping during key cache deserialization
                 Key: CASSANDRA-21731
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21731
             Project: Apache Cassandra
          Issue Type: Bug
            Reporter: Kristijonas Zalys
            Assignee: Kristijonas Zalys


Saved key-cache entries are not length-prefixed. When an entry references an 
SSTable that no longer exists, Cassandra must consume the complete serialized 
entry before reading the next one.

The stale-SSTable path invokes the format-specific skip implementation here:
 * 
[{{CacheService.java:509-518}}|https://github.com/apache/cassandra/blob/b15526b4816518e415aa1046d7eb98232a0c1151/src/java/org/apache/cassandra/service/CacheService.java#L509-L518]
 * 
[{{RowIndexEntry.java:326-335}}|https://github.com/apache/cassandra/blob/b15526b4816518e415aa1046d7eb98232a0c1151/src/java/org/apache/cassandra/io/sstable/format/big/RowIndexEntry.java#L326-L335]

{{IndexedEntry.serializeForCache}} writes the index-block count followed by one 
complete {{IndexInfo}} per block:
 * 
[{{RowIndexEntry.java:651-662}}|https://github.com/apache/cassandra/blob/b15526b4816518e415aa1046d7eb98232a0c1151/src/java/org/apache/cassandra/io/sstable/format/big/RowIndexEntry.java#L651-L662]

However, {{IndexedEntry.skipForCache}} reads the count and then consumes only 
one additional unsigned VInt rather than skipping every serialized 
{{{}IndexInfo{}}}:
 * 
[{{RowIndexEntry.java:664-671}}|https://github.com/apache/cassandra/blob/b15526b4816518e415aa1046d7eb98232a0c1151/src/java/org/apache/cassandra/io/sstable/format/big/RowIndexEntry.java#L664-L671]

This leaves the input positioned inside the skipped entry. The next cache entry 
is then decoded from {{IndexInfo}} bytes, causing cache loading to fail and 
discard the remainder of the saved cache.

Update deserialization to retain the saved SSTable format version and metadata, 
then skip every serialized {{IndexInfo}} using the appropriate serializer. Add 
deterministic regression coverage for stream alignment and saved-format-version 
handling.



--
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