Repository navigation
JAMES-4231 Compaction core (6a): chunk format and addressing - #3461
HesandaLiyanage wants to merge 5 commits into
Conversation
Versioned binary layout packing blobs into one object. Each slot keeps the caller payload and metadata (except the response-only total object size) and a CRC32C, so a slot is read with a single ranged read. A footer and a fixed trailer list the slots for later maintenance. The parser treats chunk bytes as untrusted: lengths are validated before use and malformed input only raises ChunkFormatException. Checksum mismatches raise CorruptedSlotException.
A slot address is <chunk blob id>~<offset>~<length>. The chunk blob id stays opaque: family and generation remain the concern of the blob id factory. Parsing only accepts canonical addresses, so that serializing a parsed address restores its input. New chunk ids reuse the family, generation and layout of a blob of the compacted generation, and are recognized by ChunkMarker.
Decorator meant to sit right above the storage DAO. Slot addresses are read with one ranged read and returned with their stored metadata, so compression and encryption decorators above keep working per blob. On a checksum mismatch the whole chunk is read, letting the object store verify and repair it. Ranged reads of slot addresses are refused, chunks cannot be saved and deleting them is ignored: compaction owns their lifecycle. Other blobs are delegated unchanged, as checked by the BlobStoreDAO contracts.
Normal builds replay the fuzz targets as regular tests. JAZZER_FUZZ=1 fuzzes one target, as documented in ChunkParserFuzzTest. JUnit comes from the project rather than from jazzer-junit.
| class ChunkParserFuzzTest { | ||
| private static final String NAME_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789-"; | ||
|
|
||
| @FuzzTest(maxDuration = "60s") |
| * A slot is returned with the payload and metadata it was stored with. Chunks are written and deleted by compaction | ||
| * only: saving a chunk id is refused and deleting one is ignored, as its space is reclaimed by re-compaction.</p> | ||
| */ | ||
| public class ChunkedBlobStoreDAO implements BlobStoreDAO { |
There was a problem hiding this comment.
Let's focus just on the data model for this PR ?
| import com.google.common.base.Preconditions; | ||
|
|
||
| /** Allocates chunk blob ids recognized by {@link ChunkMarker}. */ | ||
| final class ChunkIds { |
| import com.google.common.base.Preconditions; | ||
|
|
||
| /** Allocates chunk blob ids recognized by {@link ChunkMarker}. */ | ||
| final class ChunkIds { |
|
Likely issues
More oracle ideas for fuzzing the data model: Slot encoding
Whole chunk
Tooling: |
Thanks alot for the review. Working on it, will push once the fuzzing is done. |
… fuzzing - Narrow this PR to the data model: ChunkedBlobStoreDAO moves to 6b. - Canonical encoding: values UTF-8 cannot encode are refused rather than replaced, metadata names must be lowercase, and a stored total object size is rejected. - Bind the footer to its chunk with an identity repeated in the header and the footer, and store checksums little-endian so that each slot is a CRC-32C codeword. - Bound slot addresses to 200 characters, and refuse chunk ids the blob id factory would rewrite (zero-padded generation, integer overflow). - Fuzz with the suggested oracles: 10 targets of 600s, a reference decoder, a seed corpus and a dictionary. Findings are kept as inputs replayed by normal builds.
|
@chibenwa ping |
JAMES-4231 — Compaction core, part 6a: chunk format and addressing
Why item 6 is split in two
Items 2–5 of the agreed plan are merged. Item 6, the self-contained compaction core, is the largest piece, so I split it into two PRs:
ChunkedBlobStoreDAO(moved out of this PR following review), then initial compaction and re-compaction as two distinct operations driven by theBlobIdUpdatersnapshot and a Bloom filter of live references, with the 200-mail layout tests and the property-based suite.Item 7 (Guice wiring, WebAdmin, end-to-end tests) and item 8 (documentation) follow, as agreed.
Scope
New module
server/blob/blob-compaction, not wired into any server.JCHK+ version + random chunk identity, then slots, a footer (identity, slot offsets and lengths) and a fixed trailer locating the footer. Each slot stores the caller metadata, the payload and a CRC32C, so reading a slot needs neither header nor footer.<chunk blob id>~<offset>~<length>, e.g.1_689_chunk_<uuid>~1024~300or1/689/chunk/<uuid>~1024~300, recognized byChunkMarker.Dependency
Targets
feature/s3-object-compaction. Builds onChunkMarker(#3245), merged.Design notes
encodedSlotSize. Unencodable values (unpaired surrogates) are refused by the writer; non-lowercase metadata names and a storedtotal-object-sizeare rejected by the parser.CorruptedSlotException(which will trigger the whole-chunk read in 6b). A slot of the wrong length is a plainChunkFormatException.ChunkFormatException.VARCHAR(200)column.Deliberately excluded
ChunkedBlobStoreDAO, compaction algorithms, property-based tests (6b).Tests
ChunkFormatTest,SlotAddressTest,ChunkIdsTest: deterministic round trips, sizes, canonicity, and rejection of every malformed field.maxDuration = "600s", about 640 million inputs in total), with a seed corpus and a dictionary:SlotFuzzTest: canonicity; normalized round trips with exact sizes and position independence; error classes.ChunkFuzzTest: footer consistency; damaged chunks (byte changes, truncation, extension, footer of another chunk, misaligned locations); writer lifecycle; agreement withReferenceChunkDecoder, a second decoder written from the specification.ChunkIdsFuzzTest,SlotAddressFuzzTest: allocation invariants, round trips across factories and layouts, exclusive classification.ChunkIds) are committed as inputs that normal builds replay, and as unit tests.78 tests pass; Checkstyle and POM ordering checks pass. Review changes are in the last commit.
mvn -pl server/blob/blob-compaction -am testTo fuzz one target:
Follow-up
6b —
ChunkedBlobStoreDAO, compaction algorithms and property-based tests.