From 38dbc31c90deb633da32ddd621ac9a12fe3902fe Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 16 Jan 2024 02:42:56 +0000 Subject: [PATCH] fix check chksum relies on the not-sorted tablet ids. --- src/share/ob_ddl_checksum.cpp | 4 ++-- src/share/ob_ddl_checksum.h | 2 +- src/share/ob_ddl_common.cpp | 7 ++++--- src/share/ob_ddl_common.h | 7 +------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/share/ob_ddl_checksum.cpp b/src/share/ob_ddl_checksum.cpp index 188d67dd04..66205e1f78 100644 --- a/src/share/ob_ddl_checksum.cpp +++ b/src/share/ob_ddl_checksum.cpp @@ -271,7 +271,7 @@ int ObDDLChecksumOperator::get_tablet_checksum_record( const uint64_t execution_id, const uint64_t table_id, const int64_t ddl_task_id, - ObIArray &tablet_ids, + const ObIArray &tablet_ids, ObMySQLProxy &sql_proxy, common::hash::ObHashMap &tablet_checksum_status_map) { @@ -294,7 +294,7 @@ int ObDDLChecksumOperator::get_tablet_checksum_record( // check every tablet column checksum, task_id is equal to tablet_id for (int64_t i = 0; OB_SUCC(ret) && i < tablet_ids.count(); ++i) { - uint64_t last_tablet_id_id = tablet_ids.at(i).id(); + const uint64_t last_tablet_id_id = tablet_ids.at(i).id(); if (OB_FAIL(batch_tablet_array.push_back(last_tablet_id_id))) { LOG_WARN("fail to push back tablet_id_id", K(ret), K(tenant_id), K(execution_id), K(ddl_task_id)); } else { diff --git a/src/share/ob_ddl_checksum.h b/src/share/ob_ddl_checksum.h index ab794ded30..9abf2e0d6e 100644 --- a/src/share/ob_ddl_checksum.h +++ b/src/share/ob_ddl_checksum.h @@ -85,7 +85,7 @@ public: const uint64_t execution_id, const uint64_t table_id, const int64_t ddl_task_id, - ObIArray &tablet_ids, + const ObIArray &tablet_ids, ObMySQLProxy &sql_proxy, common::hash::ObHashMap &tablet_checksum_map); static int check_column_checksum( diff --git a/src/share/ob_ddl_common.cpp b/src/share/ob_ddl_common.cpp index c77de3ce1f..0a134d3ded 100644 --- a/src/share/ob_ddl_common.cpp +++ b/src/share/ob_ddl_common.cpp @@ -408,9 +408,9 @@ int ObDDLUtil::get_tablets( LOG_WARN("get table schema failed", K(ret), K(tenant_id), K(table_id)); } else if (OB_ISNULL(table_schema)) { ret = OB_TABLE_NOT_EXIST; - LOG_WARN("get table schema failed", K(ret), K(table_id)); + LOG_WARN("get table schema failed", K(ret), K(tenant_id), K(table_id)); } else if (OB_FAIL(table_schema->get_tablet_ids(tablet_ids))) { - LOG_WARN("get tablets failed", K(ret), K(*table_schema)); + LOG_WARN("get tablets failed", K(ret), KPC(table_schema)); } return ret; } @@ -2216,7 +2216,7 @@ int ObCheckTabletDataComplementOp::check_tablet_checksum_update_status( const uint64_t index_table_id, const uint64_t ddl_task_id, const int64_t execution_id, - ObIArray &tablet_ids, + const ObIArray &tablet_ids, bool &is_checksums_all_report) { int ret = OB_SUCCESS; @@ -2336,6 +2336,7 @@ int ObCheckTabletDataComplementOp::check_finish_report_checksum( LOG_WARN("fail to check report checksum finished", K(ret), K(tenant_id), K(index_table_id), K(execution_id), K(ddl_task_id)); } else if (OB_FAIL(ObDDLUtil::get_tablets(tenant_id, index_table_id, dest_tablet_ids))) { LOG_WARN("fail to get tablets", K(ret), K(tenant_id), K(index_table_id)); + } else if (OB_FALSE_IT(std::sort(dest_tablet_ids.begin(), dest_tablet_ids.end()))) { // sort in ASC order. } else if (OB_FAIL(check_tablet_checksum_update_status(tenant_id, index_table_id, ddl_task_id, execution_id, dest_tablet_ids, is_checksums_all_report))) { LOG_WARN("fail to check tablet checksum update status, maybe EAGAIN", K(ret), K(tenant_id), K(dest_tablet_ids), K(execution_id)); } else if (!is_checksums_all_report) { diff --git a/src/share/ob_ddl_common.h b/src/share/ob_ddl_common.h index 5bb29901ed..db5aeef6bf 100644 --- a/src/share/ob_ddl_common.h +++ b/src/share/ob_ddl_common.h @@ -363,11 +363,6 @@ public: const int64_t table_id, int64_t &tablet_count); - // get all tablets of a table by table_schema - static int get_tablets( - const share::schema::ObTableSchema &table_schema, - common::ObIArray &tablet_ids); - // check if the major sstable of a table are exist in all needed replicas static int check_major_sstable_complete( const uint64_t data_table_id, @@ -673,7 +668,7 @@ private: const uint64_t index_table_id, const uint64_t ddl_task_id, const int64_t execution_id, - ObIArray &tablet_ids, + const ObIArray &tablet_ids, bool &tablet_checksum_status); };