adjust checkpoint_executor spinlock to rwlock

This commit is contained in:
obdev
2022-12-06 10:08:37 +00:00
committed by ob-robot
parent 9ded1c6d28
commit b8bd38d0fd
2 changed files with 12 additions and 8 deletions

View File

@ -29,7 +29,7 @@ namespace checkpoint
{
ObCheckpointExecutor::ObCheckpointExecutor()
: lock_(common::ObLatchIds::CLOG_CKPT_LOCK),
: rwlock_(common::ObLatchIds::CLOG_CKPT_LOCK),
update_checkpoint_enabled_(false)
{
reset();
@ -95,13 +95,13 @@ void ObCheckpointExecutor::start()
void ObCheckpointExecutor::online()
{
ObSpinLockGuard guard(lock_);
WLockGuard guard(rwlock_);
update_checkpoint_enabled_ = true;
}
void ObCheckpointExecutor::offline()
{
ObSpinLockGuard guard(lock_);
WLockGuard guard(rwlock_);
update_checkpoint_enabled_ = false;
}
@ -134,7 +134,8 @@ inline void get_min_rec_scn_service_type_by_index_(int index, char* service_type
int ObCheckpointExecutor::update_clog_checkpoint()
{
int ret = OB_SUCCESS;
ObSpinLockGuard guard(lock_);
//avoid checkpoint concurrently
WLockGuard guard(rwlock_);
if (update_checkpoint_enabled_) {
ObFreezer *freezer = ls_->get_freezer();
if (OB_NOT_NULL(freezer)) {
@ -202,7 +203,7 @@ int ObCheckpointExecutor::update_clog_checkpoint()
int ObCheckpointExecutor::advance_checkpoint_by_flush(SCN recycle_scn) {
int ret = OB_SUCCESS;
ObSpinLockGuard guard(lock_);
RLockGuard guard(rwlock_);
if (update_checkpoint_enabled_) {
int tmp_ret = OB_SUCCESS;
@ -286,7 +287,7 @@ int64_t ObCheckpointExecutor::get_cannot_recycle_log_size()
int ObCheckpointExecutor::diagnose(CheckpointDiagnoseInfo &diagnose_info) const
{
int ret = OB_SUCCESS;
ObSpinLockGuard guard(lock_);
RLockGuard guard(rwlock_);
int log_type_index = 0;
diagnose_info.checkpoint_ = ls_->get_clog_checkpoint_scn();
diagnose_info.min_rec_scn_.set_max();

View File

@ -13,7 +13,7 @@
#ifndef OCEANBASE_STORAGE_OB_CHECKPOINT_EXECUTOR_H_
#define OCEANBASE_STORAGE_OB_CHECKPOINT_EXECUTOR_H_
#include "lib/lock/ob_spin_lock.h"
#include "lib/lock/ob_spin_rwlock.h" // SpinRWLock
#include "logservice/ob_log_base_type.h"
#include "logservice/ob_log_handler.h"
#include "share/scn.h"
@ -89,7 +89,10 @@ private:
// be used to avoid checkpoint concurrently,
// no need to protect handlers_[] because ls won't be destroyed(hold lshandle)
// when the public interfaces are invoked
mutable common::ObSpinLock lock_;
typedef common::SpinRWLock RWLock;
typedef common::SpinRLockGuard RLockGuard;
typedef common::SpinWLockGuard WLockGuard;
RWLock rwlock_;
bool update_checkpoint_enabled_;
};