Skip to content

Commit

Permalink
resolve the deadlock when schema change (apache#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lchangliang committed Jun 9, 2022
1 parent 9927468 commit 8b2f994
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions be/src/olap/schema_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
// delete handlers for new tablet
DeleteHandler delete_handler;
std::vector<ColumnId> return_columns;
auto base_tablet_schema = base_tablet->tablet_schema();

// begin to find deltas to convert from base tablet to new tablet so that
// obtain base tablet and new tablet's push lock and header write lock to prevent loading data
Expand All @@ -1446,7 +1447,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
std::lock_guard<std::shared_mutex> new_tablet_wlock(new_tablet->get_header_lock());
// check if the tablet has alter task
// if it has alter task, it means it is under old alter process
size_t num_cols = base_tablet->tablet_schema().num_columns();
size_t num_cols = base_tablet_schema.num_columns();
return_columns.resize(num_cols);
for (int i = 0; i < num_cols; ++i) {
return_columns[i] = i;
Expand All @@ -1456,7 +1457,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
// with rs_readers
RowsetReaderContext reader_context;
reader_context.reader_type = READER_ALTER_TABLE;
reader_context.tablet_schema = &base_tablet->tablet_schema();
reader_context.tablet_schema = &base_tablet_schema;
reader_context.need_ordered_result = true;
reader_context.delete_handler = &delete_handler;
reader_context.return_columns = &return_columns;
Expand Down Expand Up @@ -1528,8 +1529,8 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
}
}

res = delete_handler.init(base_tablet->tablet_schema(),
base_tablet->delete_predicates(), end_version);
res = delete_handler.init(base_tablet_schema, base_tablet->delete_predicates(),
end_version);
if (!res.ok()) {
LOG(WARNING) << "init delete handler failed. base_tablet="
<< base_tablet->full_name() << ", end_version=" << end_version;
Expand Down

0 comments on commit 8b2f994

Please sign in to comment.