add lock to protect slog writer's cursor_
This commit is contained in:
@ -151,6 +151,12 @@ void ObStorageLogWriter::destroy()
|
|||||||
is_inited_ = false;
|
is_inited_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObLogCursor ObStorageLogWriter::get_cur_cursor()
|
||||||
|
{
|
||||||
|
ObSpinLockGuard guard(cursor_lock_);
|
||||||
|
return cursor_;
|
||||||
|
}
|
||||||
|
|
||||||
int ObStorageLogWriter::start_log(const ObLogCursor &start_cursor)
|
int ObStorageLogWriter::start_log(const ObLogCursor &start_cursor)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -555,6 +561,7 @@ int ObStorageLogWriter::advance_file_id()
|
|||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
ObSpinLockGuard guard(cursor_lock_);
|
||||||
if (file_handler_.is_opened() && OB_FAIL(file_handler_.close())) {
|
if (file_handler_.is_opened() && OB_FAIL(file_handler_.close())) {
|
||||||
STORAGE_REDO_LOG(WARN, "Fail to close file", K(ret), K(cursor_.file_id_));
|
STORAGE_REDO_LOG(WARN, "Fail to close file", K(ret), K(cursor_.file_id_));
|
||||||
} else if (OB_FAIL(file_handler_.open(cursor_.file_id_ + 1))) {
|
} else if (OB_FAIL(file_handler_.open(cursor_.file_id_ + 1))) {
|
||||||
@ -609,6 +616,7 @@ int ObStorageLogWriter::update_log_item_cursor(
|
|||||||
ret = OB_INVALID_ARGUMENT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
LOG_ERROR("Invalid argument", K(ret), KP(log_item));
|
LOG_ERROR("Invalid argument", K(ret), KP(log_item));
|
||||||
} else {
|
} else {
|
||||||
|
ObSpinLockGuard guard(cursor_lock_);
|
||||||
log_item->start_cursor_.file_id_ = cursor_.file_id_;
|
log_item->start_cursor_.file_id_ = cursor_.file_id_;
|
||||||
log_item->start_cursor_.log_id_ = log_item->get_seq();
|
log_item->start_cursor_.log_id_ = log_item->get_seq();
|
||||||
log_item->start_cursor_.offset_ = begin_offset;
|
log_item->start_cursor_.offset_ = begin_offset;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public:
|
|||||||
virtual int start() override;
|
virtual int start() override;
|
||||||
virtual void wait() override;
|
virtual void wait() override;
|
||||||
void destroy();
|
void destroy();
|
||||||
common::ObLogCursor get_cur_cursor() const { return cursor_; }
|
common::ObLogCursor get_cur_cursor();
|
||||||
|
|
||||||
int delete_log_file(const int64_t file_id);
|
int delete_log_file(const int64_t file_id);
|
||||||
int get_using_disk_space(int64_t &using_space) const;
|
int get_using_disk_space(int64_t &using_space) const;
|
||||||
@ -136,7 +136,7 @@ private:
|
|||||||
// because it won't count the offset on the write buffer
|
// because it won't count the offset on the write buffer
|
||||||
int64_t write_offset_;
|
int64_t write_offset_;
|
||||||
common::ObLogCursor cursor_;
|
common::ObLogCursor cursor_;
|
||||||
|
common::ObSpinLock cursor_lock_;
|
||||||
common::ObLogRetryWritePolicy retry_write_policy_;
|
common::ObLogRetryWritePolicy retry_write_policy_;
|
||||||
common::ObLogWritePolicy log_write_policy_;
|
common::ObLogWritePolicy log_write_policy_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user