diff --git a/src/rootserver/ob_ddl_operator.cpp b/src/rootserver/ob_ddl_operator.cpp index e14642c9f2..6d33e811b8 100644 --- a/src/rootserver/ob_ddl_operator.cpp +++ b/src/rootserver/ob_ddl_operator.cpp @@ -1802,7 +1802,8 @@ int ObDDLOperator::drop_sequence_in_drop_column(const ObColumnSchemaV2 &column_s } int ObDDLOperator::reinit_autoinc_row(const ObTableSchema &table_schema, - common::ObMySQLTransaction &trans) + common::ObMySQLTransaction &trans, + const ObArray* alive_server_list) { int ret = OB_SUCCESS; int64_t start_time = ObTimeUtility::current_time(); @@ -1831,7 +1832,7 @@ int ObDDLOperator::reinit_autoinc_row(const ObTableSchema &table_schema, KR(ret), K(tenant_id), K(table_id), K(table_name), K(schema_version), K(column_id)); // to do // Cache can't be cleaned totally when RS change leader in autoinc_in_order mode - } else if (OB_FAIL(cleanup_autoinc_cache(table_schema))) { + } else if (OB_FAIL(cleanup_autoinc_cache(table_schema, alive_server_list))) { LOG_WARN("failed to cleanup_autoinc_caceh", KR(ret), K(tenant_id), K(table_id), K(table_name), K(schema_version), K(column_id)); } @@ -4300,7 +4301,8 @@ int ObDDLOperator::drop_table_for_not_dropped_schema( // ref https://aone.alibaba-inc.com/issue/21209472 // When tables with auto-increment columns are frequently created or deleted, if the auto-increment column cache is not cleared, the memory will grow slowly. // so every time when you drop table, if you bring auto-increment columns, clean up the corresponding cache. -int ObDDLOperator::cleanup_autoinc_cache(const ObTableSchema &table_schema) +int ObDDLOperator::cleanup_autoinc_cache(const ObTableSchema &table_schema, + const common::ObArray* alive_server_list/*nullptr*/) { int ret = OB_SUCCESS; ObAutoincrementService &autoinc_service = share::ObAutoincrementService::get_instance(); @@ -4319,7 +4321,8 @@ int ObDDLOperator::cleanup_autoinc_cache(const ObTableSchema &table_schema) if (OB_FAIL(autoinc_service.clear_autoinc_cache_all(tenant_id, table_id, autoinc_column_id, - table_schema.is_order_auto_increment_mode()))) { + table_schema.is_order_auto_increment_mode(), + alive_server_list))) { LOG_WARN("failed to clear auto-increment cache", K(tenant_id), K(table_id)); } diff --git a/src/rootserver/ob_ddl_operator.h b/src/rootserver/ob_ddl_operator.h index 0fb1298bb8..e617207b87 100644 --- a/src/rootserver/ob_ddl_operator.h +++ b/src/rootserver/ob_ddl_operator.h @@ -310,7 +310,8 @@ public: const common::ObIArray &alter_column_ids, const common::ObString *ddl_stmt_str = NULL); int reinit_autoinc_row(const ObTableSchema &table_schema, - common::ObMySQLTransaction &trans); + common::ObMySQLTransaction &trans, + const common::ObArray* alive_server_list); int create_sequence_in_create_table(share::schema::ObTableSchema &table_schema, common::ObMySQLTransaction &trans, share::schema::ObSchemaGetterGuard &schema_guard, @@ -1047,7 +1048,8 @@ private: const common::ObIArray &table_ids, common::ObMySQLTransaction &trans); - int cleanup_autoinc_cache(const share::schema::ObTableSchema &table_schema); + int cleanup_autoinc_cache(const share::schema::ObTableSchema &table_schema, + const common::ObArray* alive_server_list = nullptr); int fill_trigger_id(share::schema::ObSchemaService &schema_service, share::schema::ObTriggerInfo &new_trigger_info); diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 93d15bb316..cf470c80df 100644 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -16204,7 +16204,12 @@ int ObDDLService::new_truncate_table_in_trans(const ObIArray alive_server_list; + + if (FAILEDx(get_server_manager().get_alive_servers(nullzone, alive_server_list))) { + LOG_WARN("fail to get alive server list", KR(ret)); + } else if (OB_FAIL(ddl_operator.reinit_autoinc_row(*orig_table_schemas.at(0), trans, &alive_server_list))) { LOG_WARN("fail to reinit autoinc row", KR(ret), K(table_name)); } else if (OB_FAIL(drop_and_create_tablet(first_schema_version, orig_table_schemas, new_table_schemas, trans))) { LOG_WARN("fail to drop or create tablet", KR(ret), K(table_name), K(first_schema_version)); diff --git a/src/share/ob_autoincrement_service.cpp b/src/share/ob_autoincrement_service.cpp index 87a8ad848f..2cd0e4ffbc 100644 --- a/src/share/ob_autoincrement_service.cpp +++ b/src/share/ob_autoincrement_service.cpp @@ -335,7 +335,7 @@ int ObAutoincrementService::get_handle(AutoincParam ¶m, if (OB_SUCC(ret)) { int ignore_ret = try_periodic_refresh_global_sync_value(tenant_id, table_id, - column_id, + column_id, param.autoinc_mode_is_order_, *table_node); if (OB_SUCCESS != ignore_ret) { @@ -584,7 +584,8 @@ int ObAutoincrementService::reinit_autoinc_row(const uint64_t &tenant_id, int ObAutoincrementService::clear_autoinc_cache_all(const uint64_t tenant_id, const uint64_t table_id, const uint64_t column_id, - const bool autoinc_is_order) + const bool autoinc_is_order, + const common::ObArray* alive_server_list/*nullptr*/) { int ret = OB_SUCCESS; if (OB_SUCC(ret)) { @@ -598,9 +599,24 @@ int ObAutoincrementService::clear_autoinc_cache_all(const uint64_t tenant_id, ObHashSet server_set; if (OB_FAIL(server_set.create(PARTITION_LOCATION_SET_BUCKET_NUM))) { LOG_WARN("failed to create hash set", K(ret)); - } else if (OB_FAIL(get_server_set(tenant_id, table_id, server_set, true))) { - SHARE_LOG(WARN, "failed to get table partitions server set", K(ret)); + //to do + //fix can not get all server bug + // https://work.aone.alibaba-inc.com/issue/47360408 + } else if (OB_ISNULL(alive_server_list)) { + if (OB_FAIL(get_server_set(tenant_id, table_id, server_set, true))) { + SHARE_LOG(WARN, "failed to get table partitions server set", K(ret)); + } } else { + for (int64_t i = 0; OB_SUCC(ret) && i < alive_server_list->count(); i++) { + int err = OB_SUCCESS; + err = server_set.set_refactored(alive_server_list->at(i)); + if (OB_SUCCESS != err && OB_HASH_EXIST != err) { + ret = err; + LOG_WARN("failed to add element to set", "server", alive_server_list->at(i), K(ret)); + } + } + } + if (OB_SUCC(ret)) { const int64_t sync_timeout = SYNC_OP_TIMEOUT + TIME_SKEW; ObHashSet::iterator iter; for(iter = server_set.begin(); OB_SUCC(ret) && iter != server_set.end(); ++iter) { @@ -820,7 +836,7 @@ int ObAutoincrementService::fetch_table_node(const AutoincParam ¶m, LOG_ERROR("unexpected auto_increment_cache_size", K(auto_increment_cache_size)); auto_increment_cache_size = DEFAULT_INCREMENT_CACHE_SIZE; } - // For ORDER mode, the local cache_size is always 1, and the central(remote) cache_size + // For ORDER mode, the local cache_size is always 1, and the central(remote) cache_size // is the configuration value. const uint64_t local_cache_size = is_order ? 1 : auto_increment_cache_size; uint64_t prefetch_count = std::min(max_value / 100 / part_num, local_cache_size); diff --git a/src/share/ob_autoincrement_service.h b/src/share/ob_autoincrement_service.h index 686c8abfe4..7f6137ed0d 100644 --- a/src/share/ob_autoincrement_service.h +++ b/src/share/ob_autoincrement_service.h @@ -210,9 +210,9 @@ public: uint64_t &start_inclusive, uint64_t &end_inclusive, uint64_t &sync_value); - + int get_autoinc_value(const AutoincKey &key, uint64_t &seq_value, uint64_t &sync_value); - + int get_autoinc_value_in_batch(const uint64_t tenant_id, const common::ObIArray &keys, common::hash::ObHashMap &seq_values); @@ -292,7 +292,7 @@ public: uint64_t &sync_value, uint64_t &start_inclusive, uint64_t &end_inclusive) override; - + virtual int get_sequence_value(const AutoincKey &key, uint64_t &sequence_value) override; virtual int get_auto_increment_values( @@ -360,7 +360,8 @@ public: int clear_autoinc_cache_all(const uint64_t tenant_id, const uint64_t table_id, const uint64_t column_id, - const bool autoinc_mode_is_order); + const bool autoinc_mode_is_order, + const common::ObArray* alive_server_list = nullptr); int clear_autoinc_cache(const obrpc::ObAutoincSyncArg &arg); static int calc_next_value(const uint64_t last_next_value, diff --git a/src/share/ob_global_stat_proxy.cpp b/src/share/ob_global_stat_proxy.cpp index 320ea2f0af..d780440b44 100644 --- a/src/share/ob_global_stat_proxy.cpp +++ b/src/share/ob_global_stat_proxy.cpp @@ -506,7 +506,7 @@ int ObGlobalStatProxy::inner_get_snapshot_gc_scn_( EXTRACT_VARCHAR_FIELD_MYSQL(*result, "column_value", snapshot_gc_scn_str); char *endptr = NULL; - char buf[common::MAX_ZONE_INFO_LENGTH]; + char buf[common::MAX_ZONE_INFO_LENGTH] = {0}; if (OB_SUCC(ret)) { const int64_t str_len = snapshot_gc_scn_str.length(); const int64_t buf_len = sizeof(buf); @@ -595,7 +595,7 @@ int ObGlobalStatProxy::select_ddl_epoch_for_update( EXTRACT_VARCHAR_FIELD_MYSQL(*result, "column_value", ddl_epoch_str); char *endptr = NULL; - char buf[common::MAX_ZONE_INFO_LENGTH]; + char buf[common::MAX_ZONE_INFO_LENGTH] = {0}; if (OB_SUCC(ret)) { const int64_t str_len = ddl_epoch_str.length(); const int64_t buf_len = sizeof(buf); diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 3acc679231..870bd0c817 100644 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -515,7 +515,10 @@ inline bool index_has_tablet(const ObIndexType &index_type) || INDEX_TYPE_NORMAL_GLOBAL_LOCAL_STORAGE == index_type || INDEX_TYPE_UNIQUE_GLOBAL_LOCAL_STORAGE == index_type || INDEX_TYPE_NORMAL_GLOBAL == index_type - || INDEX_TYPE_UNIQUE_GLOBAL == index_type; + || INDEX_TYPE_UNIQUE_GLOBAL == index_type + || INDEX_TYPE_SPATIAL_LOCAL == index_type + || INDEX_TYPE_SPATIAL_GLOBAL == index_type + || INDEX_TYPE_SPATIAL_GLOBAL_LOCAL_STORAGE == index_type; } struct ObTenantTableId diff --git a/src/share/schema/ob_table_sql_service.cpp b/src/share/schema/ob_table_sql_service.cpp index a84b74f12d..26d8c2b090 100644 --- a/src/share/schema/ob_table_sql_service.cpp +++ b/src/share/schema/ob_table_sql_service.cpp @@ -293,8 +293,8 @@ int ObTableSqlService::drop_inc_partition(common::ObISQLClient &sql_client, } else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id, extra_str))) { LOG_WARN("failed to delete all histogram_stat history", K(ret)); } - } - + } + if (OB_SUCC(ret)) { int64_t affected_rows = 0; if (OB_FAIL(sql_client.write(exec_tenant_id, sql.ptr(), affected_rows))) { @@ -388,7 +388,7 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client, } else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id, &condition_str))) { LOG_WARN("failed to delete all histogram_stat history", K(ret)); } - } + } if (OB_SUCC(ret)) { int64_t affected_rows = 0; @@ -3135,7 +3135,7 @@ int ObTableSqlService::delete_from_all_table_stat(ObISQLClient &sql_client, LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_TABLE_STAT_TNAME, @@ -3162,7 +3162,7 @@ int ObTableSqlService::delete_from_all_histogram_stat(ObISQLClient &sql_client, LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_HISTOGRAM_STAT_TNAME, @@ -3219,7 +3219,7 @@ int ObTableSqlService::delete_from_all_column_stat(ObISQLClient &sql_client, LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_COLUMN_STAT_TNAME, @@ -3322,7 +3322,7 @@ int ObTableSqlService::delete_from_all_table_stat_history(ObISQLClient &sql_clie LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_TABLE_STAT_HISTORY_TNAME, dml, affected_rows))) { @@ -3347,7 +3347,7 @@ int ObTableSqlService::delete_from_all_column_stat_history(ObISQLClient &sql_cli LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_COLUMN_STAT_HISTORY_TNAME, dml, affected_rows))) { @@ -3372,7 +3372,7 @@ int ObTableSqlService::delete_from_all_histogram_stat_history(ObISQLClient &sql_ LOG_WARN("add column failed", K(ret)); } else { int64_t affected_rows = 0; - if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { + if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) { LOG_WARN("fail to assign extra condition", K(ret)); } else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_HISTOGRAM_STAT_HISTORY_TNAME,