From 15d42941f734072611283e2ff2de042aefa15fe3 Mon Sep 17 00:00:00 2001 From: Tyshawn Date: Wed, 15 Nov 2023 02:44:49 +0000 Subject: [PATCH] Add defense code for trouble shooting --- src/storage/tablet/ob_tablet.cpp | 8 ++++++++ src/storage/tablet/ob_tablet_table_store.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 414d63b0a1..c9ae101de7 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -430,6 +430,12 @@ int ObTablet::init_for_merge( ddl_kvs_ = ddl_kvs_addr; ddl_kv_count_ = ddl_kv_count; ALLOC_AND_INIT(allocator, table_store_addr_, (*this), param, (*old_table_store)); + if (OB_UNLIKELY(ddl_kv_count_ != ddl_kv_count + || ddl_kv_count != table_store_addr_.get_ptr()->get_ddl_memtable_count())) { + // This is defense code. If it runs at here, it must be a bug. And, just abort to preserve the enviroment + // for debugging. Please remove me, after the problem is found. + ob_abort(); + } } if (FAILEDx(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(), @@ -5342,6 +5348,8 @@ int64_t ObTablet::to_string(char *buf, const int64_t buf_len) const KP_(allocator), K_(tablet_meta), K_(table_store_cache), + KP_(ddl_kvs), + K_(ddl_kv_count), K_(table_store_addr), K_(storage_schema_addr), K_(next_tablet_guard), diff --git a/src/storage/tablet/ob_tablet_table_store.h b/src/storage/tablet/ob_tablet_table_store.h index 3134f42364..594c27d958 100644 --- a/src/storage/tablet/ob_tablet_table_store.h +++ b/src/storage/tablet/ob_tablet_table_store.h @@ -83,6 +83,7 @@ public: } OB_INLINE bool is_ready_for_read() const { return is_ready_for_read_; } OB_INLINE int64_t get_table_count() const { return major_tables_.count() + minor_tables_.count(); } + OB_INLINE int64_t get_ddl_memtable_count() const { return ddl_mem_sstables_.count(); } // Interfaces below that access sstable array member of table store directly does not guarantee // sstables in array were loaded