Skip to content

Commit

Permalink
[fix](index compaction)Add column unique id check before use (#47562)
Browse files Browse the repository at this point in the history
Problem Summary:

This pull request introduces a new method to check for the existence of
a column by its unique ID in the `TabletSchema` class and utilizes this
method in the compaction process to improve error handling and logging.
  • Loading branch information
qidaye authored Feb 7, 2025
1 parent b4b6721 commit a10a2a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/olap/compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,11 @@ void Compaction::construct_index_compaction_columns(RowsetWriterContext& ctx) {
continue;
}
auto col_unique_id = col_unique_ids[0];
if (!_cur_tablet_schema->has_column_unique_id(col_unique_id)) {
LOG(WARNING) << "tablet[" << _tablet->tablet_id() << "] column_unique_id["
<< col_unique_id << "] not found, will skip index compaction";
continue;
}
// Avoid doing inverted index compaction on non-slice type columns
if (!field_is_slice_type(_cur_tablet_schema->column_by_uid(col_unique_id).type())) {
continue;
Expand Down
4 changes: 4 additions & 0 deletions be/src/olap/tablet_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,10 @@ bool TabletSchema::exist_column(const std::string& field_name) const {
return _field_name_to_index.contains(StringRef {field_name});
}

bool TabletSchema::has_column_unique_id(int32_t col_unique_id) const {
return _field_id_to_index.contains(col_unique_id);
}

Status TabletSchema::have_column(const std::string& field_name) const {
if (!_field_name_to_index.contains(StringRef(field_name))) {
return Status::Error<ErrorCode::INTERNAL_ERROR>(
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/tablet_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class TabletSchema : public MetadataAdder<TabletSchema> {
Result<const TabletColumn*> column(const std::string& field_name) const;
Status have_column(const std::string& field_name) const;
bool exist_column(const std::string& field_name) const;
bool has_column_unique_id(int32_t col_unique_id) const;
const TabletColumn& column_by_uid(int32_t col_unique_id) const;
TabletColumn& mutable_column_by_uid(int32_t col_unique_id);
TabletColumn& mutable_column(size_t ordinal);
Expand Down

0 comments on commit a10a2a2

Please sign in to comment.