From acef9d21e9c87c241202a3d142df885dfcfe0e76 Mon Sep 17 00:00:00 2001 From: zh0 Date: Tue, 27 Jul 2021 11:45:21 +0800 Subject: [PATCH] fix sys tenant no fast freeze bug --- src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp | 4 ++++ src/storage/memtable/ob_memtable.h | 2 +- src/storage/ob_partition_scheduler.cpp | 9 +++++---- src/storage/ob_pg_storage.cpp | 9 ++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp b/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp index 88e7b1ebfd..6185705c67 100644 --- a/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp +++ b/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp @@ -1141,6 +1141,10 @@ int ObMvccRowCallback::trans_commit(const bool for_replay) if (value_.total_trans_node_cnt_ >= MAX_TRANS_NODE_CNT) { ctx_.set_contain_hotspot_row(); } + //print debug log when total trans node cnt great to 200 * 10000; + if (value_.total_trans_node_cnt_ > 2000000 && REACH_TIME_INTERVAL(120 * 1000 * 1000)) { + TRANS_LOG(INFO, "[FF] trans commit succ", K_(ctx), K_(value)); + } (void)ATOMIC_FAA(&value_.update_since_compact_, 1); if (value_.need_compact(for_read, for_replay)) { if (for_replay) { diff --git a/src/storage/memtable/ob_memtable.h b/src/storage/memtable/ob_memtable.h index 583ec99b21..e86dd3649e 100644 --- a/src/storage/memtable/ob_memtable.h +++ b/src/storage/memtable/ob_memtable.h @@ -362,7 +362,7 @@ public: INHERIT_TO_STRING_KV("ObITable", ObITable, KP(this), K_(timestamp), K_(active_trx_count), K_(state), K_(max_schema_version), K_(write_ref_cnt), K_(local_allocator), K_(with_accurate_log_ts_range), K_(frozen), K_(frozen_log_applied), K_(mark_finish), K_(pending_cb_cnt), K_(pending_lob_cnt), K_(pending_batch_commit_cnt), - K_(pending_elr_cnt)); + K_(pending_elr_cnt), K_(contain_hotspot_row)); private: static const int64_t OB_EMPTY_MEMSTORE_MAX_SIZE = 10L << 20; // 10MB diff --git a/src/storage/ob_partition_scheduler.cpp b/src/storage/ob_partition_scheduler.cpp index d236fadf74..803ec885cb 100644 --- a/src/storage/ob_partition_scheduler.cpp +++ b/src/storage/ob_partition_scheduler.cpp @@ -1204,8 +1204,10 @@ int ObPartitionScheduler::schedule_pg( if (OB_ENTRY_NOT_EXIST != tmp_ret) { LOG_WARN("Failed to check need fast freeze for hotspot table", K(tmp_ret), K(pg_key)); } - } else if (!need_fast_freeze) { - + } + // ignore tmp_ret + if (!need_fast_freeze) { + // do nothing } else if (OB_SUCCESS != (tmp_ret = partition_service_->minor_freeze(pg_key))) { LOG_WARN("Failed to schedule fast freeze", K(tmp_ret), K(pg_key)); } else { @@ -2510,8 +2512,7 @@ ObFastFreezeChecker::ObFastFreezeChecker(const int64_t tenant_id) reset(); if (OB_UNLIKELY(tenant_id == OB_INVALID_TENANT_ID)) { LOG_WARN("Invalid tenant id to init fast freeze checker", K(tenant_id)); - } else if (OB_SYS_TENANT_ID != tenant_id) { - // fast freeze only trigger for user tenant + } else { tenant_id_ = tenant_id; omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id_)); if (tenant_config.is_valid()) { diff --git a/src/storage/ob_pg_storage.cpp b/src/storage/ob_pg_storage.cpp index 577ae84f7b..6c5685ea8e 100644 --- a/src/storage/ob_pg_storage.cpp +++ b/src/storage/ob_pg_storage.cpp @@ -1901,7 +1901,11 @@ int ObPGStorage::check_active_mt_hotspot_row_exist(bool& has_hotspot_row, const } else if (OB_FAIL(get_all_pg_partition_keys_(pkeys))) { STORAGE_LOG(WARN, "get all pg partition keys error", K(ret), K(pkey_), K(pkeys)); } else if (pkeys.count() <= 0 || ObTimeUtility::current_time() < last_freeze_ts_ + fast_freeze_interval) { - // do nothing + if (REACH_TIME_INTERVAL(120 * 1000 * 1000)) { + TRANS_LOG(INFO, "[FF] no need to check active hotspot row", K_(pkey), + K_(last_freeze_ts), + K(fast_freeze_interval)); + } } else { ObTableHandle handle; memtable::ObMemtable* memtable = NULL; @@ -1918,6 +1922,9 @@ int ObPGStorage::check_active_mt_hotspot_row_exist(bool& has_hotspot_row, const STORAGE_LOG(ERROR, " memtable is NULL", K(ret), K(pkey_)); } else { has_hotspot_row = memtable->has_hotspot_row(); + if (has_hotspot_row && REACH_TIME_INTERVAL(120 * 1000 * 1000)) { + TRANS_LOG(INFO, "[FF] current memtable has hotspot row", K(pkey_), K(*memtable), K(fast_freeze_interval)); + } } } -- GitLab