github-actions[bot] commented on code in PR #70585:
URL: https://github.com/apache/doris/pull/70585#discussion_r4577106431
##########
be/src/cloud/cloud_snapshot_mgr.cpp:
##########
@@ -304,15 +304,18 @@ Status
CloudSnapshotMgr::_rename_index_ids(TabletSchemaPB& schema_pb,
return Status::OK();
}
- for (int i = 0; i < schema_pb.index_size(); ++i) {
- TabletIndexPB* index_pb = schema_pb.mutable_index(i);
- for (int32_t col_unique_id : index_pb->col_unique_id()) {
- auto local_index = tablet_schema->get_index(col_unique_id,
index_pb->index_type(),
-
index_pb->index_suffix_name());
- if (local_index) {
- if (index_pb->index_id() != local_index->index_id()) {
- index_pb->set_index_id(local_index->index_id());
- }
+ TabletSchemaPB target_schema_pb;
+ tablet_schema->to_schema_pb(&target_schema_pb);
+ for (auto& index_pb : *schema_pb.mutable_index()) {
+ TabletIndex source_index;
+ source_index.init_from_pb(index_pb);
+ for (const auto& target_index_pb : target_schema_pb.index()) {
+ TabletIndex target_index;
+ target_index.init_from_pb(target_index_pb);
+ // An exact index and a normalizer index can share column, type
and suffix.
+ // Match their names and definitions instead of selecting the
first index.
+ if (source_index.is_same_except_id(&target_index)) {
+ index_pb.set_index_id(target_index.index_id());
Review Comment:
[P1] Prevent collisions with unmatched source index IDs
A partial definition match can still collapse distinct indexes. For a
cross-cluster restore into an existing table, let the source have
`a(c1,id=1001)` and `b(c2,id=1002)`, and the target have `a(c1,id=1002)` with
the same definition and `b(c2,id=1003)` with a different normalizer (all
suffixes empty). `OlapTable.getSignature()` omits index properties and IDs, so
`RestoreJob` permits this combination. This loop maps `a` to 1002 but leaves
unmatched `b` at 1002, publishing duplicate `(index_id,suffix)` keys that
`IndexFileWriter::_insert_directory_into_map` rejects during subsequent
writing/compaction. The previous per-column lookup produced distinct IDs
1002/1003 for these two columns. Validate the complete assignment, including
retained unmatched IDs, before persisting; apply the same fix to
`SnapshotManager::_rename_index_ids` and add an overlapping-ID partial-match
test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]