mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 12:44:10 +00:00
* feat(meta-srv): check pending WAL tails of source regions before a repartition starts Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test(common-meta): freeze the region statistic encodings before the pending tails flag Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(meta-srv): clarify the repartition pending tails errors and pin the flag encoding Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(meta-srv): retry repartitions over pending WAL tails and pass sources without a report Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs(meta-srv): note the retained leader report in the repartition pre-check Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix(meta-srv): report pending repartition tails as region not ready and share is_false Signed-off-by: jeremyhi <fengjiachun@gmail.com> * style(meta-srv): order the repartition pre-check test imports Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com>
Region statistic compatibility
Two JSON fixtures written by the serializers at GreptimeDB commit
48aa0ed3ae151f2a436b2a5295ce8cd10ece5a9d, before the has_pending_tails field:
legacy_region_statistic.json: astore_api::region_engine::RegionStatistic, as a datanode puts it into the__region_statisticextension of a heartbeat region stat. SHA-256:e46a90c4596e38a3253c7d70c8878c1a101f111b79457f7b48b39a1561cfe6a5.legacy_region_stat.json: thecommon_meta::datanode::RegionStatthe metasrv derives from that heartbeat region stat and stores inDatanodeStatValue. SHA-256:8ae052b52653cf3e20b7e5c8085846fb027e3daaaf506f610fd363d4cf24dfb4.
Logical contents: region 4398046511105 (table 1024, region number 1), engine mito,
3 rows, a 1024-byte memtable, one 2048-byte SST, manifest version 5, flushed entry id 7.
Run the regression:
cargo nextest run -p common-meta -E 'test(test_has_pending_tails_wire)'
The test checks that both fixtures decode without pending tails and encode back to exactly the same bytes, so a statistic without pending tails keeps the encoding of a release without the field, and that a true flag travels from the heartbeat extension to the stored statistic.
Reproduce the fixtures
At the commit above, run this in a test of common_meta::datanode:
let statistic = RegionStatistic {
num_rows: 3,
memtable_size: 1024,
sst_size: 2048,
sst_num: 1,
manifest: store_api::region_engine::RegionManifestInfo::mito(5, 7, 0),
..Default::default()
};
let statistic_json = serde_json::to_vec(&statistic).unwrap();
let mut region = api::v1::meta::RegionStat {
region_id: RegionId::new(1024, 1).as_u64(),
engine: "mito".to_string(),
..Default::default()
};
region
.extensions
.insert(REGION_STATISTIC_KEY.to_string(), statistic_json.clone());
std::fs::write("legacy_region_statistic.json", statistic_json).unwrap();
let stat = RegionStat::from(®ion);
std::fs::write("legacy_region_stat.json", serde_json::to_vec(&stat).unwrap()).unwrap();