[GC] replace block_tx_start() with block_all() which blocks readonly transactions in addtion to write transactions

This commit is contained in:
yyy-hust
2023-09-09 10:44:30 +00:00
committed by ob-robot
parent 9e5ad47b75
commit 7695689b0a
3 changed files with 24 additions and 4 deletions

View File

@ -419,8 +419,8 @@ int ObGCHandler::execute_pre_remove()
if (OB_SUCC(ret) && need_check_readonly_tx) {
//follower or not in member list replica need block_tx here
if (OB_INVALID_TIMESTAMP == block_tx_ts_) {
if (OB_FAIL(ls_->block_tx_start())) {
CLOG_LOG(WARN, "failed to block_tx_start", K(ls_id), KPC(this));
if (OB_FAIL(ls_->block_all())) {
CLOG_LOG(WARN, "failed to block_all", K(ls_id), KPC(this));
} else {
block_tx_ts_ = ObClockGenerator::getClock();
}
@ -987,8 +987,8 @@ void ObGCHandler::block_ls_transfer_in_(const SCN &block_scn)
CLOG_LOG(WARN, "ls check gc state invalid", K(ls_id), K(gc_state));
} else if (is_ls_blocked_finished_(gc_state)) {
CLOG_LOG(INFO, "ls already blocked, ignore", K(ls_id), K(gc_state), K(block_scn));
} else if (OB_FAIL(ls_->block_tx_start())) {
CLOG_LOG(WARN, "block_tx_start failed", K(ls_id), K(ret));
} else if (OB_FAIL(ls_->block_all())) {
CLOG_LOG(WARN, "block_all failed", K(ls_id), K(ret));
} else if (FALSE_IT(block_tx_ts_ = ObClockGenerator::getClock())) {
} else if (OB_FAIL(ls_->set_gc_state(LSGCState::LS_BLOCKED))) {
CLOG_LOG(WARN, "set_gc_state block failed", K(ls_id), K(ret));

View File

@ -1394,6 +1394,25 @@ int ObLS::block_tx_start()
return ret;
}
int ObLS::block_all()
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ls is not inited", K(ret));
} else {
int64_t read_lock = 0;
int64_t write_lock = LSLOCKSTORAGE | LSLOCKTX;
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
// protect with lock_ to make sure there is no tablet transfer in process doing.
// transfer in must use this lock too.
if (OB_FAIL(ls_tx_svr_.block_all())) {
LOG_WARN("block_all failed", K(get_ls_id()));
}
}
return ret;
}
int ObLS::tablet_transfer_in(const ObTabletID &tablet_id)
{
int ret = OB_SUCCESS;

View File

@ -322,6 +322,7 @@ public:
// for ls gc
int block_tablet_transfer_in();
int block_tx_start();
int block_all();
// for tablet transfer
// this function is used for tablet transfer in
// it will check if it is allowed to transfer in and then