[ 
https://issues.apache.org/jira/browse/CASSANDRA-21731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kristijonas Zalys updated CASSANDRA-21731:
------------------------------------------
    Test and Documentation Plan: 
Tests:
 * ant test 
-Dtest.name=org.apache.cassandra.io.sstable.format.big.RowIndexEntryTest
 * ant checkstyle
 * GitHub Actions Ant Check passed
 * Regression coverage verifies complete IndexedEntry consumption, stream 
alignment, saved SSTable version handling, and invalid encodings.

Documentation: No user-facing documentation changes are required. This fixes 
internal key-cache deserialization behavior.

Pre-commit CI: I do not currently have pre-commit CI artifacts attached. A 
reviewer or committer may need to run pre-commit CI.
                         Status: Patch Available  (was: Open)

Patch: [https://github.com/apache/cassandra/pull/5234]

The bug is also present in cassandra-5.0 and cassandra-6.0. Corresponding 
patches can be provided based on reviewer guidance.

Related issue: CASSANDRA-10219

> 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
>          Components: Local/Startup and Shutdown
>            Reporter: Kristijonas Zalys
>            Assignee: Kristijonas Zalys
>            Priority: Normal
>
> 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