[replayengine] fix rollback of min_unreplay_log_ts

This commit is contained in:
yy
2021-06-16 11:54:12 +08:00
committed by MizuhaHimuraki
parent ede1213446
commit 795c834621
12 changed files with 149 additions and 115 deletions

View File

@ -877,41 +877,28 @@ int ObReplayStatus::set_need_filter_trans_log(const ObPartitionKey& pkey, const
return ret;
}
int ObReplayStatus::check_and_submit_task(const ObPartitionKey& pkey, const uint64_t log_id, const int64_t log_ts,
const bool need_replay, const clog::ObLogType log_type, const int64_t sw_next_replay_log_ts)
int ObReplayStatus::check_and_submit_task(const ObPartitionKey &pkey,
const uint64_t log_id,
const int64_t log_ts,
const bool need_replay,
const clog::ObLogType log_type,
const int64_t next_replay_log_ts)
{
int ret = OB_SUCCESS;
const bool is_aggre_log = (clog::OB_LOG_AGGRE == log_type);
const bool is_nop_log = (clog::OB_LOG_NOP == log_type);
// check when log slide out
//check when log slide out
const int64_t last_slide_out_log_id = get_last_slide_out_log_id();
if (OB_UNLIKELY(!is_enabled())) {
ret = OB_ERR_UNEXPECTED;
REPLAY_LOG(
ERROR, "replay status is not enabled", K(need_replay), K(pkey), K(log_id), K(log_type), K(log_ts), K(ret));
} else if (OB_UNLIKELY(!pkey.is_valid() || OB_INVALID_TIMESTAMP == log_ts || OB_INVALID_ID == log_id ||
OB_INVALID_TIMESTAMP == sw_next_replay_log_ts)) {
REPLAY_LOG(ERROR, "replay status is not enabled", K(need_replay), K(pkey), K(log_id), K(log_type),
K(log_ts), K(ret));
} else if (OB_UNLIKELY(!pkey.is_valid()
|| OB_INVALID_TIMESTAMP == log_ts
|| OB_INVALID_ID == log_id
|| OB_INVALID_TIMESTAMP == next_replay_log_ts
|| next_replay_log_ts > log_ts)) {
ret = OB_INVALID_ARGUMENT;
REPLAY_LOG(ERROR,
"invalid arguments",
K(need_replay),
K(pkey),
K(log_id),
K(log_ts),
K(log_type),
K(sw_next_replay_log_ts),
K(ret));
} else if (OB_UNLIKELY((!is_nop_log) && (sw_next_replay_log_ts > log_ts))) {
ret = OB_ERR_UNEXPECTED;
REPLAY_LOG(ERROR,
"invalid arguments",
K(need_replay),
K(pkey),
K(log_id),
K(log_ts),
K(log_type),
K(sw_next_replay_log_ts),
K(ret));
REPLAY_LOG(ERROR, "invalid arguments", K(need_replay), K(pkey), K(log_id), K(log_ts),
K(log_type), K(next_replay_log_ts), K(ret));
} else if (log_id != (last_slide_out_log_id + 1)) {
ret = OB_ERR_UNEXPECTED;
REPLAY_LOG(
@ -947,14 +934,11 @@ int ObReplayStatus::check_and_submit_task(const ObPartitionKey& pkey, const uint
} else {
{
if (!submit_log_task_.need_submit_log()) {
// do not inc next_submit_log_ts with aggre log, it's the biggest log_submit_timestamp among its
// logs
const int64_t next_submit_log_ts = is_aggre_log ? sw_next_replay_log_ts : log_ts;
// here must modify log_ts first, or may lead to the rollback of min_unreplay_log_timestamp
//here must modify log_ts first, or may lead to the rollback of min_unreplay_log_timestamp
WLockGuard wlock_guard(get_submit_log_info_rwlock());
const uint64_t old_next_submit_log_id = get_next_submit_log_id();
const int64_t old_next_submit_log_ts = get_next_submit_log_ts();
set_next_submit_log_info(log_id, next_submit_log_ts);
set_next_submit_log_info(log_id, next_replay_log_ts);
if (OB_FAIL(update_last_slide_out_log_info(log_id, log_ts))) {
REPLAY_LOG(
ERROR, "failed to update_last_slide_out_log_info", KR(ret), K(pkey), K(log_id), K(log_ts), K(log_type));