Skip to content

Commit

Permalink
[BACKPORT 2024.1][#21699] docdb: clear colocation_to_table before loa…
Browse files Browse the repository at this point in the history
…ding from metadata protobuf

Summary:
Original commit: e404d68 / D34556
At remote bootstrap, tablet metadata was replaced with the downloaded super block. When loading the new super block to memory,
colocation_to_table is not cleared. Also we set the colocation_to_table map with `emplace` method but it cannot overwrite the
old data:
```
if (schema.has_colocation_id()) {
  colocation_to_table.emplace(schema.colocation_id(), table_info);
}
```

If colocation_to_table has stale data, it can lead to corruption of SST files after a compaction because the old schema version could be used as the latest schema version and pack the unpacked rows with it, see `GetCompactionSchemaInfo` which gets the new_packing data.

Jira: DB-10579

Test Plan: PgPackedRowTest.*

Reviewers: sergei, rthallam

Reviewed By: rthallam

Subscribers: ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D34605
  • Loading branch information
Huqicheng committed Apr 30, 2024
1 parent da87c8f commit f5bd725
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/yb/tablet/tablet_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ Status KvStoreInfo::LoadTablesFromPB(
const std::string& tablet_log_prefix,
const google::protobuf::RepeatedPtrField<TableInfoPB>& pbs, const TableId& primary_table_id) {
tables.clear();
colocation_to_table.clear();
for (const auto& table_pb : pbs) {
TableInfoPtr table_info = VERIFY_RESULT(TableInfo::LoadFromPB(
tablet_log_prefix, primary_table_id, table_pb));
Expand Down

0 comments on commit f5bd725

Please sign in to comment.