[CP] Fix weak read rt shrink when tablet migration

This commit is contained in:
obdev 2024-02-10 11:49:41 +00:00 committed by ob-robot
parent dd4af47ecc
commit 8bf2034765
2 changed files with 15 additions and 15 deletions

View File

@ -1040,7 +1040,11 @@ int ObTransService::get_read_store_ctx(const ObTxReadSnapshot &snapshot,
store_ctx.timeout_,
store_ctx.tablet_id_,
*store_ctx.ls_))) {
TRANS_LOG(WARN, "replica not readable", K(ret), K(snapshot), K(ls_id), K(store_ctx));
TRANS_LOG(WARN, "replica not readable", K(ret),
K(snapshot),
K(ls_id),
K(store_ctx),
"ls_weak_read_ts", store_ctx.ls_->get_ls_wrs_handler()->get_ls_weak_read_ts());
}
// setup tx_table_guard

View File

@ -90,16 +90,14 @@ int ObLSWRSHandler::generate_ls_weak_read_snapshot_version(ObLS &ls,
SCN timestamp;
SCN gts_scn;
need_skip = false;
ObMigrationStatus status = ObMigrationStatus::OB_MIGRATION_STATUS_NONE;
ObSpinLockGuard guard(lock_);
if (!is_inited_) {
ret = OB_NOT_INIT;
STORAGE_LOG(WARN, "ObLSWRSHandler not init", K(ret), K(is_inited_), K(ls));
} else if (!is_enabled_) {
// do nothing
need_skip = true;
if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) {
if (REACH_TIME_INTERVAL(5 * 1000 * 1000)) {
STORAGE_LOG(INFO, "weak read handler not enabled", K(*this));
}
} else if (ls.get_transfer_status().get_transfer_prepare_enable()) {
@ -109,26 +107,24 @@ int ObLSWRSHandler::generate_ls_weak_read_snapshot_version(ObLS &ls,
STORAGE_LOG(INFO, "ls in transfer status", K(*this));
}
} else if (OB_FAIL(generate_weak_read_timestamp_(ls, max_stale_time, timestamp))) {
STORAGE_LOG(DEBUG, "fail to generate weak read timestamp", KR(ret), K(max_stale_time));
need_skip = true;
if (REACH_TIME_INTERVAL(5 * 1000 * 1000)) {
STORAGE_LOG(INFO, "fail to generate weak read timestamp", KR(ret), K(max_stale_time));
}
ret = OB_SUCCESS;
} else if (OB_FAIL(OB_TS_MGR.get_gts(MTL_ID(), NULL, gts_scn))) {
TRANS_LOG(WARN, "get gts scn error", K(ret), K(max_stale_time), K(*this));
} else if (OB_FAIL(ls.get_migration_status(status))
|| ObMigrationStatus::OB_MIGRATION_STATUS_NONE == status ) {
// check the weak read timestamp of the migrated ls
if (timestamp.convert_to_ts() > gts_scn.convert_to_ts() - 500 * 1000) {
STORAGE_LOG(TRACE, "ls received the latest log", K(timestamp));
// clog chases within 500ms, then clear the mark
need_skip = false;
} else {
need_skip = true;
}
} else {
int64_t snapshot_version_barrier = gts_scn.convert_to_ts() - max_stale_time;
if (timestamp.convert_to_ts() <= snapshot_version_barrier) {
// rule out these ls to avoid too old weak read timestamp
need_skip = true;
if (REACH_TIME_INTERVAL(5 * 1000 * 1000)) {
STORAGE_LOG(INFO, "wead read timestamp is too old", K(timestamp),
K(gts_scn),
K(max_stale_time),
K(*this));
}
} else {
need_skip = false;
}