adjust checkpoint_executor spinlock to rwlock
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user