Fix flashback query

This commit is contained in:
JiahuaChen 2023-07-11 21:12:12 +00:00 committed by ob-robot
parent 08d402e33f
commit 1337d35972
6 changed files with 28 additions and 13 deletions

View File

@ -178,7 +178,7 @@ TEST_F(TestTabletStatusCache, weak_read)
// mode is READ_READABLE_COMMITED, snapshot version is smaller than create commit version, return OB_SNAPSHOT_DISCARDED
ret = ObTabletCreateDeleteHelper::check_and_get_tablet(key, tablet_handle, 1 * 1000 * 1000/*timeout_us*/,
ObMDSGetTabletMode::READ_READABLE_COMMITED, 20/*snapshot*/);
ASSERT_EQ(OB_SNAPSHOT_DISCARDED, ret);
ASSERT_EQ(OB_TABLE_DEFINITION_CHANGED, ret);
ASSERT_TRUE(!tablet->tablet_status_cache_.is_valid());
// mode is READ_ALL_COMMITED, but snapshot is not max scn, not supported

File diff suppressed because one or more lines are too long

View File

@ -1024,6 +1024,7 @@ DEFINE_ORACLE_ERROR(OB_ERR_CASCADE_CONSTRAINTS_MUST_BE_SPECIFIED_TO_PERFORM_THIS
DEFINE_ORACLE_ERROR(OB_ERR_YOU_MAY_NOT_REVOKE_PRIVILEGES_FROM_YOURSELF, -5384, -1, "HY000", "you may not GRANT/REVOKE privileges to/from yourself", 1749, "you may not GRANT/REVOKE privileges to/from yourself");
DEFINE_ORACLE_ERROR_EXT(OB_ERR_MISS_ERR_LOG_MANDATORY_COLUMN, -5385, -1, "HY000", "miss mandatory column of error log table", "miss mandatory column %.*s of error log table", 38900, "miss mandatory column of error log table", "miss mandatory column %.*s of error log table");
DEFINE_ORACLE_ERROR(OB_TABLE_DEFINITION_CHANGED, -5386, ER_TABLE_DEF_CHANGED, "HY000", "Unable to read data -- Table definition has changed", 1466, "Unable to read data -- Table definition has changed");
DEFINE_ORACLE_ERROR_EXT(OB_ERR_OBJECT_STRING_DOES_NOT_EXIST, -5400, -1, "HY000", "object string does not exist", "object %.*s does not exist", 4043, "object string does not exist", "object %.*s does not exist");
DEFINE_ORACLE_ERROR(OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED, -5401, -1, "HY000", "resultant data type of virtual column is not supported", 54004, "resultant data type of virtual column is not supported");
DEFINE_ERROR(OB_ERR_GET_STACKED_DIAGNOSTICS, -5402, ER_GET_STACKED_DIAGNOSTICS_INACTIVE, "0Z002", "GET STACKED DIAGNOSTICS when handler not active");

View File

@ -784,6 +784,7 @@ constexpr int OB_ERR_CANNOT_GRANT_STRING_TO_A_ROLE = -5382;
constexpr int OB_ERR_CASCADE_CONSTRAINTS_MUST_BE_SPECIFIED_TO_PERFORM_THIS_REVOKE = -5383;
constexpr int OB_ERR_YOU_MAY_NOT_REVOKE_PRIVILEGES_FROM_YOURSELF = -5384;
constexpr int OB_ERR_MISS_ERR_LOG_MANDATORY_COLUMN = -5385;
constexpr int OB_TABLE_DEFINITION_CHANGED = -5386;
constexpr int OB_ERR_OBJECT_STRING_DOES_NOT_EXIST = -5400;
constexpr int OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED = -5401;
constexpr int OB_ERR_GET_STACKED_DIAGNOSTICS = -5402;
@ -2122,6 +2123,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ENCODING_EST_SIZE_OVERFLOW__USER_ERROR_MSG "Encoding estimated size overflow"
#define OB_INVALID_SUB_PARTITION_TYPE__USER_ERROR_MSG "It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning"
#define OB_ERR_UNEXPECTED_UNIT_STATUS__USER_ERROR_MSG "Unit status is not expected"
#define OB_AUTOINC_CACHE_NOT_EQUAL__USER_ERROR_MSG "Autoinc cache's autoinc version is not equal to request's autoinc version"
#define OB_IMPORT_NOT_IN_SERVER__USER_ERROR_MSG "Import not in service"
#define OB_CONVERT_ERROR__USER_ERROR_MSG "Convert error"
#define OB_BYPASS_TIMEOUT__USER_ERROR_MSG "Bypass timeout"
@ -2678,6 +2680,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CASCADE_CONSTRAINTS_MUST_BE_SPECIFIED_TO_PERFORM_THIS_REVOKE__USER_ERROR_MSG "CASCADE CONSTRAINTS must be specified to perform this revoke"
#define OB_ERR_YOU_MAY_NOT_REVOKE_PRIVILEGES_FROM_YOURSELF__USER_ERROR_MSG "you may not GRANT/REVOKE privileges to/from yourself"
#define OB_ERR_MISS_ERR_LOG_MANDATORY_COLUMN__USER_ERROR_MSG "miss mandatory column %.*s of error log table"
#define OB_TABLE_DEFINITION_CHANGED__USER_ERROR_MSG "Unable to read data -- Table definition has changed"
#define OB_ERR_OBJECT_STRING_DOES_NOT_EXIST__USER_ERROR_MSG "object %.*s does not exist"
#define OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED__USER_ERROR_MSG "resultant data type of virtual column is not supported"
#define OB_ERR_GET_STACKED_DIAGNOSTICS__USER_ERROR_MSG "GET STACKED DIAGNOSTICS when handler not active"
@ -4218,7 +4221,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ENCODING_EST_SIZE_OVERFLOW__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4397, Encoding estimated size overflow"
#define OB_INVALID_SUB_PARTITION_TYPE__ORA_USER_ERROR_MSG "ORA-14020: this physical attribute may not be specified for a table partition"
#define OB_ERR_UNEXPECTED_UNIT_STATUS__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4399, Unit status is not expected"
#define OB_OB_AUTOINC_CACHE_NOT_EQUAL__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4400, Autoinc cache's autoinc version is not equal to request's autoinc version"
#define OB_AUTOINC_CACHE_NOT_EQUAL__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4400, Autoinc cache's autoinc version is not equal to request's autoinc version"
#define OB_IMPORT_NOT_IN_SERVER__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4505, Import not in service"
#define OB_CONVERT_ERROR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4507, Convert error"
#define OB_BYPASS_TIMEOUT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4510, Bypass timeout"
@ -4775,6 +4778,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CASCADE_CONSTRAINTS_MUST_BE_SPECIFIED_TO_PERFORM_THIS_REVOKE__ORA_USER_ERROR_MSG "ORA-01981: CASCADE CONSTRAINTS must be specified to perform this revoke"
#define OB_ERR_YOU_MAY_NOT_REVOKE_PRIVILEGES_FROM_YOURSELF__ORA_USER_ERROR_MSG "ORA-01749: you may not GRANT/REVOKE privileges to/from yourself"
#define OB_ERR_MISS_ERR_LOG_MANDATORY_COLUMN__ORA_USER_ERROR_MSG "ORA-38900: miss mandatory column %.*s of error log table"
#define OB_TABLE_DEFINITION_CHANGED__ORA_USER_ERROR_MSG "ORA-01466: Unable to read data -- Table definition has changed"
#define OB_ERR_OBJECT_STRING_DOES_NOT_EXIST__ORA_USER_ERROR_MSG "ORA-04043: object %.*s does not exist"
#define OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED__ORA_USER_ERROR_MSG "ORA-54004: resultant data type of virtual column is not supported"
#define OB_ERR_GET_STACKED_DIAGNOSTICS__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5402, GET STACKED DIAGNOSTICS when handler not active"
@ -5954,7 +5958,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_DATA_TOO_LONG_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-12899: value too large for column %.*s (actual: %ld, maximum: %ld)"
#define OB_ERR_INVALID_DATE_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-01861: Incorrect datetime value for column '%.*s' at row %ld"
extern int g_all_ob_errnos[2093];
extern int g_all_ob_errnos[2094];
const char *ob_error_name(const int oberr);
const char* ob_error_cause(const int oberr);

View File

@ -234,7 +234,6 @@ int ObTabletCreateDeleteHelper::check_read_snapshot_by_commit_version(
const ObLSID &ls_id = tablet.get_tablet_meta().ls_id_;
const ObTabletID &tablet_id = tablet.get_tablet_meta().tablet_id_;
ObTabletStatus infered_tablet_status = tablet_status;
if (snapshot_version == ObTransVersion::MAX_TRANS_VERSION) {
// do nothing
} else if (OB_UNLIKELY(create_commit_version == ObTransVersion::INVALID_TRANS_VERSION)) {
@ -244,7 +243,7 @@ int ObTabletCreateDeleteHelper::check_read_snapshot_by_commit_version(
} else if (snapshot_version < create_commit_version) {
// read snapshot is smaller than create tablet trans version,
// no previous committed transaction
infered_tablet_status = ObTabletStatus::MAX;
ret= OB_TABLE_DEFINITION_CHANGED;
LOG_INFO("tablet status is set to MAX because read snapshot is smaller than create trans version",
K(ret), K(ls_id), K(tablet_id), K(snapshot_version), K(create_commit_version));
} else if (delete_commit_version == ObTransVersion::INVALID_TRANS_VERSION) {
@ -252,23 +251,21 @@ int ObTabletCreateDeleteHelper::check_read_snapshot_by_commit_version(
} else if (snapshot_version < delete_commit_version) {
// read snapshot is smaller than delete tablet trans version,
// previous transaction is create tablet/transfer in create tablet, so tablet status is NORMAL
infered_tablet_status = ObTabletStatus::NORMAL;
LOG_INFO("tablet status is set to NORMAL because read snapshot is smaller than delete trans version",
K(ret), K(ls_id), K(tablet_id), K(snapshot_version), K(delete_commit_version));
} else {
// snapshot_version >= user_data.delete_commit_version_
// do nothing
ret = ObTabletStatus::TRANSFER_OUT_DELETED == tablet_status ? OB_TABLET_NOT_EXIST : OB_TABLE_NOT_EXIST;
LOG_INFO("tablet is deleted or transfer out deleted",
K(ret), K(ls_id), K(tablet_id), K(tablet_status), K(snapshot_version), K(delete_commit_version));
}
if (OB_FAIL(ret)) {
} else if (ObTabletStatus::NORMAL == infered_tablet_status || ObTabletStatus::TRANSFER_IN == infered_tablet_status) {
} else if (ObTabletStatus::NORMAL == tablet_status || ObTabletStatus::TRANSFER_IN == tablet_status) {
if (OB_UNLIKELY(tablet.is_empty_shell())) {
ret = OB_TABLET_NOT_EXIST;
LOG_WARN("tablet is empty shell", K(ret), K(ls_id), K(tablet_id), K(snapshot_version), K(create_commit_version));
}
} else if (ObTabletStatus::MAX == infered_tablet_status) {
ret = OB_SNAPSHOT_DISCARDED;
LOG_WARN("no valid tablet status can be read", K(ret), K(ls_id), K(tablet_id), K(snapshot_version), K(create_commit_version));
} else {
ret = OB_TABLET_NOT_EXIST;
}

View File

@ -148,7 +148,7 @@ inline int TestTabletHelper::create_tablet(
if (FAILEDx(t3m->compare_and_swap_tablet(key, tablet_handle, tablet_handle))) {
STORAGE_LOG(WARN, "failed to compare and swap tablet", K(ret), K(ls_id), K(tablet_id));
} else if OB_FAIL (ls_tablet_svr->tablet_id_set_.set(tablet_id)){
} else if (OB_FAIL(ls_tablet_svr->tablet_id_set_.set(tablet_id))){
STORAGE_LOG(WARN, "set tablet id failed", K(ret), K(tablet_id));
}
}