fix(mito2): keep SST replacements coherent with metadata counts

Signed-off-by: aumnertic <aumnertic@gmail.com>
This commit is contained in:
aumnertic
2026-11-26 00:22:42 -05:00
parent 1b5fa8d082
commit 42517b37e3
7 changed files with 440 additions and 386 deletions
+18 -15
View File
@@ -8,7 +8,7 @@ rewriting, benchmarking, and replacing Parquet SST files:
properties.
- `parquetbench`: benchmark reads from a local GreptimeDB SST or an SST in a
configured object store.
- `sst-replace`: replace an existing Mito SST object and update its manifest
- `sst-replace`: install a replacement Mito SST and update its manifest
metadata.
These are development and recovery tools, not stable user-facing interfaces.
@@ -183,17 +183,19 @@ iteration from profiling.
## Replace an existing region SST
> **Warning:** `sst-replace` mutates both an SST object and its region manifest.
> Stop the datanode that owns the region and back up the target SST and manifest
> before using `--confirm`. The SST write happens before the manifest update, so
> an interrupted or failed operation may require restoring the backup.
Stop the datanode that owns the region and back up its manifest before using
`--confirm`. The command writes the replacement under a fresh file ID, then
publishes one manifest edit that swaps the old ID for the new one. Readers of
the previous manifest can still use the original object.
`sst-replace` replaces the contents of an existing SST file ID. It does not add
a new file ID to a region. The command requires the replacement to have the same
row count and row-group count recorded in the manifest when those manifest
values are nonzero. It does not validate schema or row contents. The replacement
is loaded into memory in full, so ensure the machine has enough memory for the
SST.
The target must be a locally owned, unshared Parquet SST. The replacement must
belong to the same source region and time index and
match the manifest row and row-group counts when those counts are known.
Its footer must provide exact time bounds. Missing primary-key bounds remain
unknown. Index sidecars belong to the original file ID. When the manifest has
a sequence fence or preserves per-row sequences, the command compares the
sequence column of both files before retaining those guarantees. Allow memory
for both SSTs during validation.
Start with the default dry run using a local replacement file:
@@ -237,10 +239,11 @@ $GREPTIME datanode sst-replace \
--confirm
```
The confirmed operation overwrites the existing SST object, recalculates file
size and row-group statistics, and appends a manifest edit for the existing file
ID. Restart the datanode and validate queries against the region before removing
the backup.
The confirmed operation prints the new SST path and manifest version. Restart
the datanode and validate queries against the region before removing the
backup. To repair bounds or stale cache entries left by an older in-place
replacement, use its current object-store path as `--replacement-object` and
its current manifest ID as `--file-id`.
## Recommended rewrite and replacement workflow