From 60eeedcb2734067a25a8c98a86a25e322903ac56 Mon Sep 17 00:00:00 2001 From: saltonz Date: Thu, 20 Jul 2023 10:42:17 +0000 Subject: [PATCH] [bugfix] add memtable array lock int table store --- src/storage/tablet/ob_tablet_table_store.cpp | 9 ++++++++- src/storage/tablet/ob_tablet_table_store.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/storage/tablet/ob_tablet_table_store.cpp b/src/storage/tablet/ob_tablet_table_store.cpp index d5827859c..b37025891 100755 --- a/src/storage/tablet/ob_tablet_table_store.cpp +++ b/src/storage/tablet/ob_tablet_table_store.cpp @@ -40,6 +40,8 @@ ObTabletTableStore::ObTabletTableStore() ddl_sstables_(), meta_major_tables_(), memtables_(), + ddl_mem_sstables_(), + memtables_lock_(), is_ready_for_read_(false), is_inited_(false) { @@ -867,6 +869,7 @@ int ObTabletTableStore::get_table(const ObITable::TableKey &table_key, ObITable } if (table_key.is_memtable()) { + common::SpinRLockGuard guard(memtables_lock_); if (OB_FAIL(memtables_.find(table_key, table))) { LOG_WARN("fail to get memtable", K(ret), K(table_key), K_(memtables)); } @@ -895,7 +898,7 @@ int ObTabletTableStore::get_read_tables( const bool allow_no_ready_read) const { int ret = OB_SUCCESS; - + common::SpinRLockGuard guard(memtables_lock_); if (OB_UNLIKELY(snapshot_version < 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(snapshot_version)); @@ -973,6 +976,7 @@ int ObTabletTableStore::get_memtables( common::ObIArray &memtables, const bool need_active) const { + common::SpinRLockGuard guard(memtables_lock_); int ret = OB_SUCCESS; for (int64_t i = 0; OB_SUCC(ret) && i < memtables_.count(); ++i) { if (OB_ISNULL(memtables_[i])) { @@ -990,6 +994,7 @@ int ObTabletTableStore::get_memtables( int ObTabletTableStore::update_memtables(const common::ObIArray &memtables) { int ret = OB_SUCCESS; + common::SpinWLockGuard guard(memtables_lock_); if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); @@ -1001,6 +1006,7 @@ int ObTabletTableStore::update_memtables(const common::ObIArray