From 3c5468522ada5679fa27fa195fad64091bce16c6 Mon Sep 17 00:00:00 2001 From: JiahuaChen Date: Tue, 27 Jun 2023 03:12:28 +0000 Subject: [PATCH] Return non empty shell tablet for READ_ALL_COMMITED mode --- .../storage/test_tablet_status_cache.cpp | 2 +- src/storage/tablet/ob_tablet.cpp | 21 ------------------- src/storage/tablet/ob_tablet.h | 1 - src/storage/tablet/ob_tablet_common.h | 4 ++-- .../tablet/ob_tablet_create_delete_helper.cpp | 5 +++-- 5 files changed, 6 insertions(+), 27 deletions(-) diff --git a/mittest/mtlenv/storage/test_tablet_status_cache.cpp b/mittest/mtlenv/storage/test_tablet_status_cache.cpp index 5685a9d095..1c6bf4ef4f 100644 --- a/mittest/mtlenv/storage/test_tablet_status_cache.cpp +++ b/mittest/mtlenv/storage/test_tablet_status_cache.cpp @@ -325,7 +325,7 @@ TEST_F(TestTabletStatusCache, get_transfer_out_tablet) // mode is READ_ALL_COMMITED, snapshot status is transfer out deleted, not allow to get ret = ObTabletCreateDeleteHelper::check_and_get_tablet(key, tablet_handle, 1 * 1000 * 1000/*timeout_us*/, ObMDSGetTabletMode::READ_ALL_COMMITED, ObTransVersion::MAX_TRANS_VERSION/*snapshot*/); - ASSERT_EQ(OB_TABLET_NOT_EXIST, ret); + ASSERT_EQ(OB_SUCCESS, ret); // begin transfer out deleted transaction user_data.tablet_status_ = ObTabletStatus::DELETED; diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index b19782a2e4..1628fd0c47 100755 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -5719,27 +5719,6 @@ int ObTablet::check_new_mds_with_cache( return ret; } -int ObTablet::check_tablet_status_for_read_all_committed() -{ - int ret = OB_SUCCESS; - const ObTabletID &tablet_id = get_tablet_meta().tablet_id_; - const ObLSID &ls_id = get_tablet_meta().ls_id_; - ObTabletCreateDeleteMdsUserData user_data; - - if (OB_FAIL(get_tablet_status(share::SCN::max_scn(), user_data, 0/*timeout*/))) { - LOG_WARN("failed to get tablet status", K(ret), K(ls_id), K(tablet_id)); - } else if (ObTabletStatus::NORMAL == user_data.tablet_status_ - || ObTabletStatus::TRANSFER_IN == user_data.tablet_status_ - || ObTabletStatus::TRANSFER_OUT == user_data.tablet_status_) { - // do nothing - } else { - ret = OB_TABLET_NOT_EXIST; - LOG_WARN("tablet does not exist", K(ret), K(ls_id), K(tablet_id), K(user_data)); - } - - return ret; -} - int ObTablet::set_tablet_status( const ObTabletCreateDeleteMdsUserData &tablet_status, mds::MdsCtx &ctx) diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index edde1c6f20..eb87d45b01 100755 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -487,7 +487,6 @@ public: mds::MdsDumpKV *&kv); int check_new_mds_with_cache(const int64_t snapshot_version, const int64_t timeout); - int check_tablet_status_for_read_all_committed(); int check_schema_version_with_cache(const int64_t schema_version, const int64_t timeout); int check_snapshot_readable_with_cache(const int64_t snapshot_version, const int64_t timeout); int set_tablet_status( diff --git a/src/storage/tablet/ob_tablet_common.h b/src/storage/tablet/ob_tablet_common.h index 07570e2662..934875e898 100644 --- a/src/storage/tablet/ob_tablet_common.h +++ b/src/storage/tablet/ob_tablet_common.h @@ -26,8 +26,8 @@ namespace storage isolation level in a database. READ_ALL_COMMITED: - Read committed row after transaction committed, except deletion transaction. - Return tablet in NORMAL, TRANSFER_IN, TRANSFER_OUT status. + Read committed row after transaction committed, except empty shell. + Return tablet in NORMAL, TRANSFER_IN, TRANSFER_OUT, DELETED, TRANSFER_OUT_DELETED status. Not return CREATING and DELETING who was abandoned from 4.2. In addition, you should NOT pass read timeout under this mode. diff --git a/src/storage/tablet/ob_tablet_create_delete_helper.cpp b/src/storage/tablet/ob_tablet_create_delete_helper.cpp index 116cfb3d06..ef1f123298 100755 --- a/src/storage/tablet/ob_tablet_create_delete_helper.cpp +++ b/src/storage/tablet/ob_tablet_create_delete_helper.cpp @@ -114,8 +114,9 @@ int ObTabletCreateDeleteHelper::check_and_get_tablet( if (OB_UNLIKELY(snapshot_version != ObTransVersion::MAX_TRANS_VERSION)) { ret = OB_NOT_SUPPORTED; LOG_WARN("read all committed mode should only pass max scn", K(ret), K(key), K(mode), K(snapshot_version)); - } else if (OB_FAIL(tablet->check_tablet_status_for_read_all_committed())) { - LOG_WARN("failed to check tablet status", K(ret), K(key)); + } else if (OB_UNLIKELY(tablet->is_empty_shell())) { + ret = OB_TABLET_NOT_EXIST; + LOG_WARN("tablet is empty shell", K(ret), K(tablet->get_tablet_meta())); } } else if (ObMDSGetTabletMode::READ_READABLE_COMMITED == mode) { if (OB_FAIL(tablet->check_new_mds_with_cache(snapshot_version, timeout_us))) {