github-actions[bot] commented on code in PR #31055: URL: https://github.com/apache/doris/pull/31055#discussion_r1502820521
########## be/src/olap/schema_change.cpp: ########## @@ -934,80 +937,81 @@ } { std::lock_guard<std::shared_mutex> wrlock(_mutex); - _tablet_ids_in_converting.insert(new_tablet->tablet_id()); + _tablet_ids_in_converting.insert(_new_tablet->tablet_id()); } int64_t real_alter_version = 0; + sc_params.enable_unique_key_merge_on_write = + _new_tablet->enable_unique_key_merge_on_write(); res = _convert_historical_rowsets(sc_params, &real_alter_version); { std::lock_guard<std::shared_mutex> wrlock(_mutex); - _tablet_ids_in_converting.erase(new_tablet->tablet_id()); + _tablet_ids_in_converting.erase(_new_tablet->tablet_id()); } if (!res) { break; } - if (new_tablet->keys_type() == UNIQUE_KEYS && - new_tablet->enable_unique_key_merge_on_write()) { - res = _calc_delete_bitmap_for_mow_table(new_tablet, real_alter_version); + if (_new_tablet->keys_type() == UNIQUE_KEYS && + _new_tablet->enable_unique_key_merge_on_write()) { + res = _calc_delete_bitmap_for_mow_table(real_alter_version); if (!res) { break; } } else { // set state to ready - std::lock_guard<std::shared_mutex> new_wlock(new_tablet->get_header_lock()); + std::lock_guard<std::shared_mutex> new_wlock(_new_tablet->get_header_lock()); SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); - res = new_tablet->set_tablet_state(TabletState::TABLET_RUNNING); + res = _new_tablet->set_tablet_state(TabletState::TABLET_RUNNING); if (!res) { break; } - new_tablet->save_meta(); + _new_tablet->save_meta(); } } while (false); if (res) { // _validate_alter_result should be outside the above while loop. // to avoid requiring the header lock twice. - res = _validate_alter_result(new_tablet, request); + res = _validate_alter_result(request); } // if failed convert history data, then just remove the new tablet if (!res) { - LOG(WARNING) << "failed to alter tablet. base_tablet=" << base_tablet->tablet_id() - << ", drop new_tablet=" << new_tablet->tablet_id(); + LOG(WARNING) << "failed to alter tablet. base_tablet=" << _base_tablet->tablet_id() + << ", drop new_tablet=" << _new_tablet->tablet_id(); // do not drop the new tablet and its data. GC thread will } return res; } -bool SchemaChangeHandler::tablet_in_converting(int64_t tablet_id) { +bool SchemaChangeJob::tablet_in_converting(int64_t tablet_id) { std::shared_lock rdlock(_mutex); return _tablet_ids_in_converting.find(tablet_id) != _tablet_ids_in_converting.end(); } -Status SchemaChangeHandler::_get_versions_to_be_changed( - TabletSharedPtr base_tablet, std::vector<Version>* versions_to_be_changed, - RowsetSharedPtr* max_rowset) { - RowsetSharedPtr rowset = base_tablet->get_rowset_with_max_version(); +Status SchemaChangeJob::_get_versions_to_be_changed(std::vector<Version>* versions_to_be_changed, + RowsetSharedPtr* max_rowset) { + RowsetSharedPtr rowset = _base_tablet->get_rowset_with_max_version(); if (rowset == nullptr) { return Status::Error<ALTER_DELTA_DOES_NOT_EXISTS>("Tablet has no version. base_tablet={}", - base_tablet->tablet_id()); + _base_tablet->tablet_id()); } *max_rowset = rowset; - RETURN_IF_ERROR(base_tablet->capture_consistent_versions_unlocked( + RETURN_IF_ERROR(_base_tablet->capture_consistent_versions_unlocked( Version(0, rowset->version().second), versions_to_be_changed, false, false)); return Status::OK(); } // The `real_alter_version` parameter indicates that the version of [0-real_alter_version] is // converted from a base tablet, only used for the mow table now. -Status SchemaChangeHandler::_convert_historical_rowsets(const SchemaChangeParams& sc_params, - int64_t* real_alter_version) { +Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc_params, Review Comment: warning: function '_convert_historical_rowsets' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc_params, ^ ``` <details> <summary>Additional context</summary> **be/src/olap/schema_change.cpp:1009:** 128 lines including whitespace and comments (threshold 80) ```cpp Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc_params, ^ ``` </details> ########## be/src/olap/schema_change.cpp: ########## @@ -652,97 +658,110 @@ Status VSchemaChangeWithSorting::_external_sorting(vector<RowsetSharedPtr>& src_ return Status::OK(); } -Status SchemaChangeHandler::process_alter_tablet_v2(const TAlterTabletReqV2& request) { +Status VLocalSchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset_reader, + RowsetWriter* rowset_writer, + BaseTabletSPtr new_tablet, + TabletSchemaSPtr base_tablet_schema, + TabletSchemaSPtr new_tablet_schema) { + Defer defer {[&]() { + // remove the intermediate rowsets generated by internal sorting + for (auto& row_set : _src_rowsets) { + _local_storage_engine.add_unused_rowset(row_set); + } + }}; + _pending_rs_guards.clear(); + return VBaseSchemaChangeWithSorting::_inner_process(rowset_reader, rowset_writer, new_tablet, + base_tablet_schema, new_tablet_schema); +} + +Status SchemaChangeJob::process_alter_tablet(const TAlterTabletReqV2& request) { if (!request.__isset.desc_tbl) { return Status::Error<INVALID_ARGUMENT>( "desc_tbl is not set. Maybe the FE version is not equal to the BE " "version."); } + if (_base_tablet == nullptr) { + return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", + request.base_tablet_id); + } + if (_new_tablet == nullptr) { + return Status::Error<TABLE_NOT_FOUND>("fail to find new tablet. new_tablet={}", + request.new_tablet_id); + } LOG(INFO) << "begin to do request alter tablet: base_tablet_id=" << request.base_tablet_id << ", new_tablet_id=" << request.new_tablet_id << ", alter_version=" << request.alter_version; - TabletSharedPtr base_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.base_tablet_id); - if (base_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", - request.base_tablet_id); - } // Lock schema_change_lock util schema change info is stored in tablet header - std::unique_lock<std::mutex> schema_change_lock(base_tablet->get_schema_change_lock(), + std::unique_lock<std::mutex> schema_change_lock(_base_tablet->get_schema_change_lock(), std::try_to_lock); if (!schema_change_lock.owns_lock()) { return Status::Error<TRY_LOCK_FAILED>("failed to obtain schema change lock. base_tablet={}", request.base_tablet_id); } - Status res = _do_process_alter_tablet_v2(request); + Status res = _do_process_alter_tablet(request); LOG(INFO) << "finished alter tablet process, res=" << res; return res; } -std::shared_mutex SchemaChangeHandler::_mutex; -std::unordered_set<int64_t> SchemaChangeHandler::_tablet_ids_in_converting; +SchemaChangeJob::SchemaChangeJob(StorageEngine& local_storage_engine, + const TAlterTabletReqV2& request) + : _local_storage_engine(local_storage_engine) { + _base_tablet = _local_storage_engine.tablet_manager()->get_tablet(request.base_tablet_id); + _new_tablet = _local_storage_engine.tablet_manager()->get_tablet(request.new_tablet_id); + if (_base_tablet && _new_tablet) { + _base_tablet_schema = std::make_shared<TabletSchema>(); + _base_tablet_schema->update_tablet_columns(*_base_tablet->tablet_schema(), request.columns); + // During a schema change, the extracted columns of a variant should not be included in the tablet schema. + // This is because the schema change for a variant needs to ignore the extracted columns. + // Otherwise, the schema types in different rowsets might be inconsistent. When performing a schema change, + // the complete variant is constructed by reading all the sub-columns of the variant. + _new_tablet_schema = _new_tablet->tablet_schema()->copy_without_extracted_columns(); + } +} // In the past schema change and rollup will create new tablet and will wait for txns starting before the task to finished // It will cost a lot of time to wait and the task is very difficult to understand. // In alter task v2, FE will call BE to create tablet and send an alter task to BE to convert historical data. // The admin should upgrade all BE and then upgrade FE. // Should delete the old code after upgrade finished. -Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2& request) { - Status res = Status::OK(); - TabletSharedPtr base_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.base_tablet_id); - if (base_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", - request.base_tablet_id); - } - - signal::tablet_id = base_tablet->get_table_id(); - - // new tablet has to exist - TabletSharedPtr new_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.new_tablet_id); - if (new_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find new tablet. new_tablet={}", - request.new_tablet_id); - } +Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& request) { Review Comment: warning: function '_do_process_alter_tablet' has cognitive complexity of 58 (threshold 50) [readability-function-cognitive-complexity] ```cpp Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& request) { ^ ``` <details> <summary>Additional context</summary> **be/src/olap/schema_change.cpp:735:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (_new_tablet->tablet_state() != TABLET_NOTREADY) { ^ ``` **be/src/olap/schema_change.cpp:756:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!base_migration_rlock.owns_lock()) { ^ ``` **be/src/olap/schema_change.cpp:761:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!new_migration_rlock.owns_lock()) { ^ ``` **be/src/olap/schema_change.cpp:783:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp for (int i = 0; i < num_cols; ++i) { ^ ``` **be/src/olap/schema_change.cpp:793:** nesting level increased to 1 ```cpp SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); ^ ``` **be/src/util/trace.h:32:** expanded from macro 'SCOPED_SIMPLE_TRACE_IF_TIMEOUT' ```cpp SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, LOG(WARNING)) ^ ``` **be/src/util/trace.h:44:** expanded from macro 'SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT' ```cpp SCOPED_CLEANUP({ \ ^ ``` **be/src/util/scoped_cleanup.h:33:** expanded from macro 'SCOPED_CLEANUP' ```cpp auto VARNAME_LINENUM(scoped_cleanup) = MakeScopedCleanup([&] { func_body }); ^ ``` **be/src/olap/schema_change.cpp:793:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); ^ ``` **be/src/util/trace.h:32:** expanded from macro 'SCOPED_SIMPLE_TRACE_IF_TIMEOUT' ```cpp SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, LOG(WARNING)) ^ ``` **be/src/util/trace.h:49:** expanded from macro 'SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT' ```cpp if (VARNAME_LINENUM(cost_us) >= VARNAME_LINENUM(timeout_us)) { \ ^ ``` **be/src/olap/schema_change.cpp:796:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp do { ^ ``` **be/src/olap/schema_change.cpp:799:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!_get_versions_to_be_changed(&versions_to_be_changed, &max_rowset)) { ^ ``` **be/src/olap/schema_change.cpp:805:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (max_rowset == nullptr || max_rowset->end_version() < request.alter_version) { ^ ``` **be/src/olap/schema_change.cpp:805:** +1 ```cpp if (max_rowset == nullptr || max_rowset->end_version() < request.alter_version) { ^ ``` **be/src/olap/schema_change.cpp:808:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp (max_rowset == nullptr ? 0 : max_rowset->end_version()), ^ ``` **be/src/olap/schema_change.cpp:838:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_new_tablet->modify_rowsets(empty_vec, rowsets_to_delete)); ^ ``` **be/src/common/status.h:541:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/schema_change.cpp:838:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_new_tablet->modify_rowsets(empty_vec, rowsets_to_delete)); ^ ``` **be/src/common/status.h:543:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/schema_change.cpp:855:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR( ^ ``` **be/src/common/status.h:541:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/schema_change.cpp:855:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR( ^ ``` **be/src/common/status.h:543:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/schema_change.cpp:857:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (rs_splits.empty()) { ^ ``` **be/src/olap/schema_change.cpp:873:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!res) { ^ ``` **be/src/olap/schema_change.cpp:899:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp do { ^ ``` **be/src/olap/schema_change.cpp:900:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!res) { ^ ``` **be/src/olap/schema_change.cpp:905:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR( ^ ``` **be/src/common/status.h:541:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/schema_change.cpp:905:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR( ^ ``` **be/src/common/status.h:543:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/schema_change.cpp:914:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp switch (request.alter_tablet_type) { ^ ``` **be/src/olap/schema_change.cpp:925:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (request.__isset.materialized_view_params) { ^ ``` **be/src/olap/schema_change.cpp:949:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!res) { ^ ``` **be/src/olap/schema_change.cpp:953:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (_new_tablet->keys_type() == UNIQUE_KEYS && ^ ``` **be/src/olap/schema_change.cpp:956:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!res) { ^ ``` **be/src/olap/schema_change.cpp:959:** +1, nesting level increased to 2 ```cpp } else { ^ ``` **be/src/olap/schema_change.cpp:962:** nesting level increased to 3 ```cpp SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); ^ ``` **be/src/util/trace.h:32:** expanded from macro 'SCOPED_SIMPLE_TRACE_IF_TIMEOUT' ```cpp SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, LOG(WARNING)) ^ ``` **be/src/util/trace.h:44:** expanded from macro 'SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT' ```cpp SCOPED_CLEANUP({ \ ^ ``` **be/src/util/scoped_cleanup.h:33:** expanded from macro 'SCOPED_CLEANUP' ```cpp auto VARNAME_LINENUM(scoped_cleanup) = MakeScopedCleanup([&] { func_body }); ^ ``` **be/src/olap/schema_change.cpp:962:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); ^ ``` **be/src/util/trace.h:32:** expanded from macro 'SCOPED_SIMPLE_TRACE_IF_TIMEOUT' ```cpp SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, LOG(WARNING)) ^ ``` **be/src/util/trace.h:49:** expanded from macro 'SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT' ```cpp if (VARNAME_LINENUM(cost_us) >= VARNAME_LINENUM(timeout_us)) { \ ^ ``` **be/src/olap/schema_change.cpp:964:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!res) { ^ ``` **be/src/olap/schema_change.cpp:971:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (res) { ^ ``` **be/src/olap/schema_change.cpp:978:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!res) { ^ ``` </details> ########## be/src/olap/schema_change.cpp: ########## @@ -652,97 +658,110 @@ return Status::OK(); } -Status SchemaChangeHandler::process_alter_tablet_v2(const TAlterTabletReqV2& request) { +Status VLocalSchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset_reader, + RowsetWriter* rowset_writer, + BaseTabletSPtr new_tablet, + TabletSchemaSPtr base_tablet_schema, + TabletSchemaSPtr new_tablet_schema) { + Defer defer {[&]() { + // remove the intermediate rowsets generated by internal sorting + for (auto& row_set : _src_rowsets) { + _local_storage_engine.add_unused_rowset(row_set); + } + }}; + _pending_rs_guards.clear(); + return VBaseSchemaChangeWithSorting::_inner_process(rowset_reader, rowset_writer, new_tablet, + base_tablet_schema, new_tablet_schema); +} + +Status SchemaChangeJob::process_alter_tablet(const TAlterTabletReqV2& request) { if (!request.__isset.desc_tbl) { return Status::Error<INVALID_ARGUMENT>( "desc_tbl is not set. Maybe the FE version is not equal to the BE " "version."); } + if (_base_tablet == nullptr) { + return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", + request.base_tablet_id); + } + if (_new_tablet == nullptr) { + return Status::Error<TABLE_NOT_FOUND>("fail to find new tablet. new_tablet={}", + request.new_tablet_id); + } LOG(INFO) << "begin to do request alter tablet: base_tablet_id=" << request.base_tablet_id << ", new_tablet_id=" << request.new_tablet_id << ", alter_version=" << request.alter_version; - TabletSharedPtr base_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.base_tablet_id); - if (base_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", - request.base_tablet_id); - } // Lock schema_change_lock util schema change info is stored in tablet header - std::unique_lock<std::mutex> schema_change_lock(base_tablet->get_schema_change_lock(), + std::unique_lock<std::mutex> schema_change_lock(_base_tablet->get_schema_change_lock(), std::try_to_lock); if (!schema_change_lock.owns_lock()) { return Status::Error<TRY_LOCK_FAILED>("failed to obtain schema change lock. base_tablet={}", request.base_tablet_id); } - Status res = _do_process_alter_tablet_v2(request); + Status res = _do_process_alter_tablet(request); LOG(INFO) << "finished alter tablet process, res=" << res; return res; } -std::shared_mutex SchemaChangeHandler::_mutex; -std::unordered_set<int64_t> SchemaChangeHandler::_tablet_ids_in_converting; +SchemaChangeJob::SchemaChangeJob(StorageEngine& local_storage_engine, + const TAlterTabletReqV2& request) + : _local_storage_engine(local_storage_engine) { + _base_tablet = _local_storage_engine.tablet_manager()->get_tablet(request.base_tablet_id); + _new_tablet = _local_storage_engine.tablet_manager()->get_tablet(request.new_tablet_id); + if (_base_tablet && _new_tablet) { + _base_tablet_schema = std::make_shared<TabletSchema>(); + _base_tablet_schema->update_tablet_columns(*_base_tablet->tablet_schema(), request.columns); + // During a schema change, the extracted columns of a variant should not be included in the tablet schema. + // This is because the schema change for a variant needs to ignore the extracted columns. + // Otherwise, the schema types in different rowsets might be inconsistent. When performing a schema change, + // the complete variant is constructed by reading all the sub-columns of the variant. + _new_tablet_schema = _new_tablet->tablet_schema()->copy_without_extracted_columns(); + } +} // In the past schema change and rollup will create new tablet and will wait for txns starting before the task to finished // It will cost a lot of time to wait and the task is very difficult to understand. // In alter task v2, FE will call BE to create tablet and send an alter task to BE to convert historical data. // The admin should upgrade all BE and then upgrade FE. // Should delete the old code after upgrade finished. -Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2& request) { - Status res = Status::OK(); - TabletSharedPtr base_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.base_tablet_id); - if (base_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find base tablet. base_tablet={}", - request.base_tablet_id); - } - - signal::tablet_id = base_tablet->get_table_id(); - - // new tablet has to exist - TabletSharedPtr new_tablet = - ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_tablet( - request.new_tablet_id); - if (new_tablet == nullptr) { - return Status::Error<TABLE_NOT_FOUND>("fail to find new tablet. new_tablet={}", - request.new_tablet_id); - } +Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& request) { Review Comment: warning: function '_do_process_alter_tablet' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& request) { ^ ``` <details> <summary>Additional context</summary> **be/src/olap/schema_change.cpp:729:** 256 lines including whitespace and comments (threshold 80) ```cpp Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& request) { ^ ``` </details> ########## be/src/olap/schema_change.cpp: ########## @@ -1144,19 +1142,16 @@ // @static // Analyze the mapping of the column and the mapping of the filter key -Status SchemaChangeHandler::_parse_request(const SchemaChangeParams& sc_params, - BlockChanger* changer, bool* sc_sorting, - bool* sc_directly) { +Status SchemaChangeJob::parse_request(const SchemaChangeParams& sc_params, Review Comment: warning: function 'parse_request' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status SchemaChangeJob::parse_request(const SchemaChangeParams& sc_params, ^ ``` <details> <summary>Additional context</summary> **be/src/olap/schema_change.cpp:1144:** 150 lines including whitespace and comments (threshold 80) ```cpp Status SchemaChangeJob::parse_request(const SchemaChangeParams& sc_params, ^ ``` </details> ########## be/src/olap/schema_change.cpp: ########## @@ -934,80 +937,81 @@ } { std::lock_guard<std::shared_mutex> wrlock(_mutex); - _tablet_ids_in_converting.insert(new_tablet->tablet_id()); + _tablet_ids_in_converting.insert(_new_tablet->tablet_id()); } int64_t real_alter_version = 0; + sc_params.enable_unique_key_merge_on_write = + _new_tablet->enable_unique_key_merge_on_write(); res = _convert_historical_rowsets(sc_params, &real_alter_version); { std::lock_guard<std::shared_mutex> wrlock(_mutex); - _tablet_ids_in_converting.erase(new_tablet->tablet_id()); + _tablet_ids_in_converting.erase(_new_tablet->tablet_id()); } if (!res) { break; } - if (new_tablet->keys_type() == UNIQUE_KEYS && - new_tablet->enable_unique_key_merge_on_write()) { - res = _calc_delete_bitmap_for_mow_table(new_tablet, real_alter_version); + if (_new_tablet->keys_type() == UNIQUE_KEYS && + _new_tablet->enable_unique_key_merge_on_write()) { + res = _calc_delete_bitmap_for_mow_table(real_alter_version); if (!res) { break; } } else { // set state to ready - std::lock_guard<std::shared_mutex> new_wlock(new_tablet->get_header_lock()); + std::lock_guard<std::shared_mutex> new_wlock(_new_tablet->get_header_lock()); SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD); - res = new_tablet->set_tablet_state(TabletState::TABLET_RUNNING); + res = _new_tablet->set_tablet_state(TabletState::TABLET_RUNNING); if (!res) { break; } - new_tablet->save_meta(); + _new_tablet->save_meta(); } } while (false); if (res) { // _validate_alter_result should be outside the above while loop. // to avoid requiring the header lock twice. - res = _validate_alter_result(new_tablet, request); + res = _validate_alter_result(request); } // if failed convert history data, then just remove the new tablet if (!res) { - LOG(WARNING) << "failed to alter tablet. base_tablet=" << base_tablet->tablet_id() - << ", drop new_tablet=" << new_tablet->tablet_id(); + LOG(WARNING) << "failed to alter tablet. base_tablet=" << _base_tablet->tablet_id() + << ", drop new_tablet=" << _new_tablet->tablet_id(); // do not drop the new tablet and its data. GC thread will } return res; } -bool SchemaChangeHandler::tablet_in_converting(int64_t tablet_id) { +bool SchemaChangeJob::tablet_in_converting(int64_t tablet_id) { Review Comment: warning: method 'tablet_in_converting' can be made static [readability-convert-member-functions-to-static] be/src/olap/schema_change.h:279: ```diff - bool tablet_in_converting(int64_t tablet_id); + static bool tablet_in_converting(int64_t tablet_id); ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org