ct/l0: preserve the produce-time record crc on the read path - #31375
Merged
Conversation
Previously, when L0 materialized record batches from the payloads in object storage, we were resetting the record-batch crc and rederiving it from the materialized payload data, rather than using the crc in object storage that were written at produce time. This meant that we wouldn't have detected a corrupted bit at rest when served from object storage. Updates the record-batch materialization code to use the record-batch crc and only recompute the header_crc (needed since neither the placeholder nor the object storage batch have the full materialized-batch header_crc with correct offset and size).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes L0 record-batch materialization to preserve the produce-time record CRC from object storage (so corruption-at-rest remains detectable), while still recomputing the internal header CRC where needed for the materialized header.
Changes:
- Preserve produce-time
record_batch_header.crcduring placeholder/header merging rather than recomputing it over materialized bytes. - Recompute
size_bytesandheader_crcfor the merged/materialized header to reflect updated offsets/sizes. - Add an end-to-end regression test that flips a bit in an uploaded L0 object and asserts the client rejects it.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/v/cloud_topics/tests/end_to_end_test.cc | Adds regression coverage for detecting corrupted L0 object data via client CRC checks. |
| src/v/cloud_topics/tests/BUILD | Adds the chunked_vector dependency needed by the new test harness usage. |
| src/v/cloud_topics/level_zero/stm/placeholder.cc | Preserves produce-time batch CRC while recomputing size/header CRC for the merged header. |
| src/v/cloud_topics/level_zero/reader/materialized_extent.cc | Stops recomputing produce-time CRC during raft-data batch materialization (but needs to keep header CRC consistent after mutating the header). |
Comment on lines
+104
to
106
| // base_offset comes from the placeholder; the serialized batch has none. | ||
| header.base_offset = kafka::offset_cast(ext.meta.base_offset); | ||
| header.crc = model::crc_record_batch(header, records_bytes); | ||
| crc::crc32c crc; | ||
| model::crc_record_batch_header(crc, header); | ||
| header.header_crc = crc.value(); | ||
| model::record_batch batch( |
| } | ||
| } | ||
|
|
||
| // Regression test for an incorrect integity check: previous versions of |
Lazin
approved these changes
Jul 31, 2026
Collaborator
|
/backport v26.2.x |
Collaborator
|
/backport v26.1.x |
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, when L0 materialized record batches from the payloads in object storage, we were resetting the record-batch crc and rederiving it from the materialized payload data, rather than using the crc in object storage that were written at produce time. This meant that we wouldn't have detected a corrupted bit at rest when served from object storage.
Updates the record-batch materialization code to use the record-batch crc and only recompute the header_crc (needed since neither the placeholder nor the object storage batch have the full materialized-batch header_crc with correct offset and size).
Backports Required
Release Notes
Bug Fixes