fix readable sites judged by weak reads in the standby database
This commit is contained in:
@ -113,7 +113,7 @@ int ObIDService::submit_log_(const int64_t last_id, const int64_t limited_id)
|
|||||||
TRANS_LOG(WARN, "invalid argument", K(ret), K_(service_type), K_(latest_log_ts), K_(self));
|
TRANS_LOG(WARN, "invalid argument", K(ret), K_(service_type), K_(latest_log_ts), K_(self));
|
||||||
} else if (ObTimeUtility::current_time() - submit_log_ts_ > SUBMIT_LOG_ALARM_INTERVAL) {
|
} else if (ObTimeUtility::current_time() - submit_log_ts_ > SUBMIT_LOG_ALARM_INTERVAL) {
|
||||||
if (log_interval_.reach()) {
|
if (log_interval_.reach()) {
|
||||||
TRANS_LOG(WARN, "submit log callback use too mush time", K_(submit_log_ts), K_(service_type), K_(latest_log_ts), K_(self));
|
TRANS_LOG(WARN, "submit log callback use too mush time", K_(submit_log_ts), K_(cb), K_(service_type), K_(latest_log_ts), K_(self));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (last_id < 0 || limited_id < 0) {
|
} else if (last_id < 0 || limited_id < 0) {
|
||||||
|
|||||||
@ -1353,7 +1353,7 @@ int ObTransService::check_replica_readable_(const SCN &snapshot,
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
bool leader = false;
|
bool leader = false;
|
||||||
int64_t epoch = 0;
|
int64_t epoch = 0;
|
||||||
bool readable = check_ls_readable_(ls, snapshot);
|
bool readable = check_ls_readable_(ls, snapshot, src);
|
||||||
if (!readable) {
|
if (!readable) {
|
||||||
if (OB_FAIL(ls.get_tx_svr()->get_tx_ls_log_adapter()->get_role(leader, epoch))) {
|
if (OB_FAIL(ls.get_tx_svr()->get_tx_ls_log_adapter()->get_role(leader, epoch))) {
|
||||||
TRANS_LOG(WARN, "get replica status fail", K(ls_id));
|
TRANS_LOG(WARN, "get replica status fail", K(ls_id));
|
||||||
@ -1364,10 +1364,12 @@ int ObTransService::check_replica_readable_(const SCN &snapshot,
|
|||||||
// to compatible with SQL's retry-logic, trigger re-choose replica
|
// to compatible with SQL's retry-logic, trigger re-choose replica
|
||||||
ret = OB_REPLICA_NOT_READABLE;
|
ret = OB_REPLICA_NOT_READABLE;
|
||||||
} else {
|
} else {
|
||||||
if (OB_SUCC(wait_follower_readable_(ls, expire_ts, snapshot))) {
|
if (OB_SUCC(wait_follower_readable_(ls, expire_ts, snapshot, src))) {
|
||||||
TRANS_LOG(INFO, "read from follower", K(snapshot), K(snapshot), K(ls));
|
TRANS_LOG(INFO, "read from follower", K(snapshot), K(snapshot), K(ls));
|
||||||
} else {
|
} else if (MTL_IS_PRIMARY_TENANT()) {
|
||||||
ret = OB_NOT_MASTER;
|
ret = OB_NOT_MASTER;
|
||||||
|
} else {
|
||||||
|
ret = OB_REPLICA_NOT_READABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1375,12 +1377,14 @@ int ObTransService::check_replica_readable_(const SCN &snapshot,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObTransService::check_ls_readable_(ObLS &ls, const SCN &snapshot)
|
bool ObTransService::check_ls_readable_(ObLS &ls,
|
||||||
|
const SCN &snapshot,
|
||||||
|
const ObTxReadSnapshot::SRC src)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
bool readable = false;
|
bool readable = false;
|
||||||
SCN scn;
|
SCN scn;
|
||||||
if (MTL_IS_PRIMARY_TENANT()) {
|
if (ObTxReadSnapshot::SRC::WEAK_READ_SERVICE == src || MTL_IS_PRIMARY_TENANT()) {
|
||||||
readable = snapshot <= ls.get_ls_wrs_handler()->get_ls_weak_read_ts();
|
readable = snapshot <= ls.get_ls_wrs_handler()->get_ls_weak_read_ts();
|
||||||
} else if (OB_FAIL(ls.get_ls_replica_readable_scn(scn))) {
|
} else if (OB_FAIL(ls.get_ls_replica_readable_scn(scn))) {
|
||||||
TRANS_LOG(WARN, "get ls replica readable scn fail", K(ret), K(ls.get_ls_id()));
|
TRANS_LOG(WARN, "get ls replica readable scn fail", K(ret), K(ls.get_ls_id()));
|
||||||
@ -1395,7 +1399,8 @@ bool ObTransService::check_ls_readable_(ObLS &ls, const SCN &snapshot)
|
|||||||
|
|
||||||
int ObTransService::wait_follower_readable_(ObLS &ls,
|
int ObTransService::wait_follower_readable_(ObLS &ls,
|
||||||
const int64_t expire_ts,
|
const int64_t expire_ts,
|
||||||
const SCN &snapshot)
|
const SCN &snapshot,
|
||||||
|
const ObTxReadSnapshot::SRC src)
|
||||||
{
|
{
|
||||||
int ret = OB_REPLICA_NOT_READABLE;
|
int ret = OB_REPLICA_NOT_READABLE;
|
||||||
int64_t compare_timeout = 0;
|
int64_t compare_timeout = 0;
|
||||||
@ -1411,7 +1416,7 @@ int ObTransService::wait_follower_readable_(ObLS &ls,
|
|||||||
do {
|
do {
|
||||||
if (OB_UNLIKELY(ObClockGenerator::getClock() >= expire_ts)) {
|
if (OB_UNLIKELY(ObClockGenerator::getClock() >= expire_ts)) {
|
||||||
ret = OB_TIMEOUT;
|
ret = OB_TIMEOUT;
|
||||||
} else if (check_ls_readable_(ls, snapshot)) {
|
} else if (check_ls_readable_(ls, snapshot, src)) {
|
||||||
TRANS_LOG(WARN, "read from follower", K(snapshot), K(ls.get_ls_id()), K(tenant_id));
|
TRANS_LOG(WARN, "read from follower", K(snapshot), K(ls.get_ls_id()), K(tenant_id));
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
} else if (ObClockGenerator::getClock() >= compare_expired_time) {
|
} else if (ObClockGenerator::getClock() >= compare_expired_time) {
|
||||||
|
|||||||
@ -221,7 +221,9 @@ int check_replica_readable_(const share::SCN &snapshot,
|
|||||||
const share::ObLSID &ls_id,
|
const share::ObLSID &ls_id,
|
||||||
const int64_t expired_ts,
|
const int64_t expired_ts,
|
||||||
ObLS &ls);
|
ObLS &ls);
|
||||||
bool check_ls_readable_(ObLS &ls, const share::SCN &snapshot);
|
bool check_ls_readable_(ObLS &ls,
|
||||||
|
const share::SCN &snapshot,
|
||||||
|
const ObTxReadSnapshot::SRC src);
|
||||||
int build_tx_commit_msg_(const ObTxDesc &tx, ObTxCommitMsg &msg);
|
int build_tx_commit_msg_(const ObTxDesc &tx, ObTxCommitMsg &msg);
|
||||||
int abort_participants_(const ObTxDesc &tx_desc);
|
int abort_participants_(const ObTxDesc &tx_desc);
|
||||||
int acquire_local_snapshot_(const share::ObLSID &ls_id, share::SCN &snapshot);
|
int acquire_local_snapshot_(const share::ObLSID &ls_id, share::SCN &snapshot);
|
||||||
@ -341,7 +343,8 @@ int get_tx_table_guard_(ObLS *ls,
|
|||||||
void fetch_cflict_tx_ids_from_mem_ctx_to_desc_(memtable::ObMvccAccessCtx &acc_ctx);
|
void fetch_cflict_tx_ids_from_mem_ctx_to_desc_(memtable::ObMvccAccessCtx &acc_ctx);
|
||||||
int wait_follower_readable_(ObLS &ls,
|
int wait_follower_readable_(ObLS &ls,
|
||||||
const int64_t expire_ts,
|
const int64_t expire_ts,
|
||||||
const share::SCN &snapshot);
|
const share::SCN &snapshot,
|
||||||
|
const ObTxReadSnapshot::SRC src);
|
||||||
MonotonicTs get_req_receive_mts_();
|
MonotonicTs get_req_receive_mts_();
|
||||||
// include tx api refacored for future
|
// include tx api refacored for future
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user