Skip to content

properties: persist blob raw sizes in optional SST metadata - #345

Draft
hbisheng wants to merge 17 commits into
tikv:masterfrom
hbisheng:bh-titan-raw-size-map
Draft

hbisheng wants to merge 17 commits into
tikv:masterfrom
hbisheng:bh-titan-raw-size-map

Conversation

@hbisheng

@hbisheng hbisheng commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Problem and change

Store known raw value lengths in the optional TitanDB.blob_raw_size_map.v1 SST property. Each entry is (blob file number, offset, raw value length). Sort and deduplicate entries by address, then query the property with binary search during compaction.

  • Flush passes the original value length to collectors. Compaction reuses input metadata or reads the blob to backfill a missing length.
  • A bounded per-CF cache passes lengths from blob GC to flush. GC still writes the existing BlobIndex format to WAL and memtable.
  • Unknown lengths are omitted. Auxiliary backfill read failures preserve the index and allow table construction to continue. Early WAL recovery flush leaves lengths unknown until a later rewrite.
  • Add backfill attempt/failure counters and a default-off CF option.
  • Preserve real blob-output errors through builder cleanup, keep CF storage alive while a builder uses it, and fix reader cleanup/error handling exercised by backfill.

This is a draft PoC for tikv/tikv#20419. BlobIndex, blob files and WAL keep their existing formats. The new SST property is optional; old readers can ignore it and old compactions can drop it.

Dependencies and validation

Requires the companion RocksDB hint interfaces. rust-rocksdb and TiKV consume the new option, counters and explicit length argument.

  • Current head: all 17 RawSizePropertiesTest tests passed; the companion TiKV code set passed all 56 engine_rocks tests in a serial run.
  • Earlier code set: real three-replica experiments covered storm reproduction and compaction repair, GC relocation, cache loss, restart, bidirectional snapshots, downgrade and re-upgrade.
  • The early-recovery simplification has a targeted test: skip reads during recovery, keep data readable, then backfill through compaction and reuse the property after another restart.
  • Current-head full cluster rerun, release-branch upgrade matrices and long-running tests remain pending.

The new property adds 24 bytes per distinct known blob address. First-time backfill reads and decompresses values; its cost depends on the data and storage.

Companion draft PRs

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Stop emitting buffered blob results after a write or finish failure, so parsing a cached key cannot clear the error and publish indices to the removed output. Add transient write-failure coverage and exercise raw-size metadata through level merge and fallback.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Transfer the completed arrays instead of copying their full payload. The collector is finished and no longer consumes either string.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Return immediately after attempting a level-merge write so a backfill lookup cannot clear an output failure and discard buffered records. Treat a required missing compression dictionary as corruption and release the reader on open failures. Extend rotation coverage to legacy indices with dictionary buffering and verify dictionary failure classification and cleanup.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Keep blob storage alive while an SST builder is completing an entry, including concurrent CF drop and obsolete-file purge. Test the backfill boundary with statistics disabled so stats ownership cannot mask early release.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Acquire CF storage under the metadata mutex and keep it alive through construction. A normal builder whose CF has already disappeared starts with ColumnFamilyDropped; recovery retains its read-only metadata-free path. Cover both creation-time and in-flight deletion in the regression.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Capture the aggregate builder status before cleanup destroys the blob builder. Cover Add-time append failures without file rotation, with raw-size properties both enabled and disabled, and require the original SSTs and values to survive.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Treat auxiliary raw-size read errors during WAL recovery as unknown sizes. Preserve every original BlobIndex and warn at most once per output SST. Keep normal backfill and data-write error handling unchanged.

Cover I/O and corruption failures at the first and later entries, a second restart, and subsequent compaction backfill.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
…risons

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant