From 276a09d8f45c02d26899095ba40552aeb1570a5c Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 21 Mar 2023 15:12:03 +0000 Subject: [PATCH] Updating max_commit_ts from ls to tenant level --- src/storage/tx/ob_tx_loop_worker.cpp | 23 ++++++++++++----------- src/storage/tx/ob_tx_loop_worker.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/storage/tx/ob_tx_loop_worker.cpp b/src/storage/tx/ob_tx_loop_worker.cpp index 58c38a1b58..bbb313071a 100644 --- a/src/storage/tx/ob_tx_loop_worker.cpp +++ b/src/storage/tx/ob_tx_loop_worker.cpp @@ -111,6 +111,12 @@ void ObTxLoopWorker::run1() (void)scan_all_ls_(can_gc_tx, can_gc_retain_ctx); + // TODO shanyan.g + // 1) We use max(max_commit_ts, gts_cache) as read snapshot, + // but now we adopt updating max_commit_ts periodly to avoid getting gts cache cost + // 2) Some time later, we will revert current modification when performance problem solved; + update_max_commit_ts_(); + time_used = ObTimeUtility::current_time() - start_time_us; if (time_used < LOOP_INTERVAL) { @@ -186,12 +192,6 @@ int ObTxLoopWorker::scan_all_ls_(bool can_tx_gc, bool can_gc_retain_ctx) // keep alive, interval = 100ms do_keep_alive_(cur_ls_ptr, min_start_scn, status); - // TODO shanyan.g - // 1) We use max(max_commit_ts, gts_cache) as read snapshot, - // but now we adopt updating max_commit_ts periodly to avoid getting gts cache cost - // 2) Some time later, we will revert current modification when performance problem solved; - update_max_commit_ts_(cur_ls_ptr); - if (can_gc_retain_ctx) { do_retain_ctx_gc_(cur_ls_ptr); } @@ -229,11 +229,12 @@ void ObTxLoopWorker::do_tx_gc_(ObLS *ls_ptr, SCN &min_start_scn, MinStartScnStat UNUSED(ret); } -void ObTxLoopWorker::update_max_commit_ts_(ObLS *ls_ptr) +void ObTxLoopWorker::update_max_commit_ts_() { int ret = OB_SUCCESS; SCN snapshot; const int64_t expire_ts = ObClockGenerator::getClock() + 1000000; // 1s + ObTransService *txs = NULL; do { int64_t n = ObClockGenerator::getClock(); @@ -248,11 +249,11 @@ void ObTxLoopWorker::update_max_commit_ts_(ObLS *ls_ptr) } else if (OB_UNLIKELY(!snapshot.is_valid())) { ret = OB_ERR_UNEXPECTED; TRANS_LOG(WARN, "invalid snapshot from gts", K(snapshot)); + } else if (OB_ISNULL(txs = MTL(ObTransService *))) { + ret = OB_ERR_UNEXPECTED; + TRANS_LOG(ERROR, "unexpected transaction service", K(ret), KP(txs)); } else { - if (NULL != ls_ptr) { - ls_ptr->get_tx_svr()->get_trans_service() - ->get_tx_version_mgr().update_max_commit_ts(snapshot, false); - } + txs->get_tx_version_mgr().update_max_commit_ts(snapshot, false); } } while (OB_EAGAIN == ret); } diff --git a/src/storage/tx/ob_tx_loop_worker.h b/src/storage/tx/ob_tx_loop_worker.h index d0d59ba430..b6fdc93683 100644 --- a/src/storage/tx/ob_tx_loop_worker.h +++ b/src/storage/tx/ob_tx_loop_worker.h @@ -58,7 +58,7 @@ private: int scan_all_ls_(bool can_tx_gc, bool can_gc_retain_ctx); void do_keep_alive_(ObLS *ls, const share::SCN &min_start_scn, MinStartScnStatus status); // 100ms void do_tx_gc_(ObLS *ls, share::SCN &min_start_scn, MinStartScnStatus &status); // 15s - void update_max_commit_ts_(ObLS *ls); + void update_max_commit_ts_(); void do_retain_ctx_gc_(ObLS * ls); // 15s private: