seperate snapshot version for get_tablet and get_read_tables

This commit is contained in:
Handora
2024-07-26 07:54:17 +00:00
committed by ob-robot
parent 66bf45c312
commit 489f709899
7 changed files with 45 additions and 17 deletions

View File

@ -133,6 +133,7 @@ int ObStorageTableGuard::refresh_and_protect_table(ObRelativeTable &relative_tab
tablet_id,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
store_ctx_.mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx(),
store_ctx_.mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx(),
iter,
relative_table.allow_not_ready()))) {
TRANS_LOG(WARN, "fail to get", K(store_ctx_.mvcc_acc_ctx_.tx_id_), K(ret));

View File

@ -1458,6 +1458,9 @@ int ObMultipleMerge::refresh_tablet_iter()
const int64_t remain_timeout = THIS_WORKER.get_timeout_remain();
const share::ObLSID &ls_id = access_ctx_->ls_id_;
const common::ObTabletID &tablet_id = get_table_param_->tablet_iter_.get_tablet()->get_tablet_meta().tablet_id_;
const int64_t snapshot_version = get_table_param_->sample_info_.is_no_sample()
? access_ctx_->store_ctx_->mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx()
: INT64_MAX;
if (OB_UNLIKELY(remain_timeout <= 0)) {
ret = OB_TIMEOUT;
LOG_WARN("timeout reached", K(ret), K(ls_id), K(tablet_id), K(remain_timeout));
@ -1469,9 +1472,8 @@ int ObMultipleMerge::refresh_tablet_iter()
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(
tablet_id,
remain_timeout,
get_table_param_->sample_info_.is_no_sample()
? access_ctx_->store_ctx_->mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx()
: INT64_MAX,
snapshot_version,
snapshot_version,
get_table_param_->tablet_iter_,
false/*allow_not_ready*/))) {
LOG_WARN("failed to refresh tablet iterator", K(ret), K(ls_id), K_(get_table_param), KP_(access_param));

View File

@ -184,6 +184,7 @@ int ObUniqueIndexChecker::scan_table_with_column_checksum(
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(tablet_id_,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
param.snapshot_version_,
param.snapshot_version_,
iterator, allow_not_ready))) {
if (OB_REPLICA_NOT_READABLE == ret) {
ret = OB_EAGAIN;

View File

@ -1176,7 +1176,8 @@ int ObComplementWriteTask::do_local_scan()
LOG_WARN("ddl sim failure", K(ret), KPC(param_));
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(param_->orig_tablet_id_,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
param_->snapshot_version_, iterator, allow_not_ready))) {
param_->snapshot_version_, param_->snapshot_version_,
iterator, allow_not_ready))) {
if (OB_REPLICA_NOT_READABLE == ret) {
ret = OB_EAGAIN;
} else {

View File

@ -2377,7 +2377,10 @@ int ObLSTabletService::check_allow_to_read()
int ObLSTabletService::get_read_tables(
const common::ObTabletID tablet_id,
const int64_t timeout_us,
const int64_t snapshot_version,
// snapshot used for get tablet for mds
const int64_t snapshot_version_for_tablet,
// snapshot used for filter tables in table_store
const int64_t snapshot_version_for_tables,
ObTabletTableIterator &iter,
const bool allow_no_ready_read)
{
@ -2391,9 +2394,12 @@ int ObLSTabletService::get_read_tables(
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K_(is_inited));
} else if (OB_UNLIKELY(!tablet_id.is_valid() || snapshot_version < 0)) {
} else if (OB_UNLIKELY(!tablet_id.is_valid() ||
snapshot_version_for_tables < 0 ||
snapshot_version_for_tablet < 0)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K(tablet_id), K(snapshot_version));
LOG_WARN("invalid arguments", K(ret), K(tablet_id), K(snapshot_version_for_tablet),
K(snapshot_version_for_tables));
} else if (FALSE_IT(allow_to_read_mgr_.load_allow_to_read_info(allow_to_read))) {
} else if (!allow_to_read) {
ret = OB_REPLICA_NOT_READABLE;
@ -2402,15 +2408,17 @@ int ObLSTabletService::get_read_tables(
} else if (OB_FAIL(ObTabletCreateDeleteHelper::check_and_get_tablet(key, handle,
timeout_us,
ObMDSGetTabletMode::READ_READABLE_COMMITED,
snapshot_version))) {
snapshot_version_for_tablet))) {
if (OB_TABLET_NOT_EXIST != ret) {
LOG_WARN("fail to check and get tablet", K(ret), K(key), K(timeout_us), K(snapshot_version));
LOG_WARN("fail to check and get tablet", K(ret), K(key), K(timeout_us),
K(snapshot_version_for_tablet), K(snapshot_version_for_tables));
}
} else if (OB_UNLIKELY(!handle.is_valid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error, invalid tablet handle", K(ret), K(handle));
} else if (OB_FAIL(handle.get_obj()->get_read_tables(snapshot_version, iter, allow_no_ready_read))) {
LOG_WARN("fail to get read tables", K(ret), K(handle), K(tablet_id), K(snapshot_version),
} else if (OB_FAIL(handle.get_obj()->get_read_tables(snapshot_version_for_tables, iter, allow_no_ready_read))) {
LOG_WARN("fail to get read tables", K(ret), K(handle), K(tablet_id),
K(snapshot_version_for_tablet), K(snapshot_version_for_tables),
K(iter), K(allow_no_ready_read));
}
return ret;
@ -5894,7 +5902,7 @@ int ObLSTabletService::get_multi_ranges_cost(
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret));
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, iter))) {
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, max_snapshot_version, iter))) {
LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version));
} else {
ObPartitionMultiRangeSpliter spliter;
@ -5924,7 +5932,7 @@ int ObLSTabletService::split_multi_ranges(
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret));
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, iter))) {
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, max_snapshot_version, iter))) {
LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version));
} else {
ObPartitionMultiRangeSpliter spliter;
@ -5965,7 +5973,7 @@ int ObLSTabletService::estimate_row_count(
} else {
const int64_t snapshot_version = -1 == param.frozen_version_ ?
GET_BATCH_ROWS_READ_SNAPSHOT_VERSION : param.frozen_version_;
if (OB_FAIL(get_read_tables(param.tablet_id_, timeout_us, snapshot_version, tablet_iter, false))) {
if (OB_FAIL(get_read_tables(param.tablet_id_, timeout_us, snapshot_version, snapshot_version, tablet_iter, false))) {
if (OB_TABLET_NOT_EXIST != ret) {
LOG_WARN("failed to get tablet_iter", K(ret), K(snapshot_version), K(param));
}
@ -6030,7 +6038,7 @@ int ObLSTabletService::estimate_block_count_and_row_count(
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K_(is_inited));
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, INT64_MAX, tablet_iter, false/*allow_no_ready_read*/))) {
} else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, INT64_MAX, INT64_MAX, tablet_iter, false/*allow_no_ready_read*/))) {
LOG_WARN("failed to get read tables", K(ret));
}

View File

@ -269,7 +269,17 @@ public:
int get_read_tables(
const common::ObTabletID tablet_id,
const int64_t timeout_us,
const int64_t snapshot_version,
// snapshot_version_for_tablet refers to the version provided to the
// multi-data source for obtaining multi-version tablet status. Generally,
// it is the txn's read version provided to obtain the corresponding
// tablet status. Sometimes(for example, during write), we also provide
// INT64_MAX to get the latest tablet status.
const int64_t snapshot_version_for_tablet,
// snapshot_version_for_tables refers to the version provided to the
// table_store to obtain the required tables (including memtables and
// sstables) for the caller. The function use the snapshot version to
// filter the unnecessary tables and confirm the OB_SNAPSHOT_DISCARDED
const int64_t snapshot_version_for_tables,
ObTabletTableIterator &iter,
const bool allow_no_ready_read = false);
int check_allow_to_read();

View File

@ -114,6 +114,11 @@ int ObStorageTableGuard::refresh_and_protect_table(ObRelativeTable &relative_tab
} else if (OB_FAIL(store_ctx_.ls_->get_tablet_svr()->get_read_tables(
tablet_id,
remain_timeout,
// snapshot_for_tablet retrieves the versioned tablet status. For write
// operations, we need to acquire the latest tablet status; otherwise,
// we may obtain an outdated tablet status during the transfer process.
share::SCN::max_scn().get_val_for_tx(),
// snapshot_for_tables filters the tables during get_read_tables
store_ctx_.mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx(),
iter,
relative_table.allow_not_ready()))) {