提交 e5081695 编写于 作者: O obdev 提交者: wangzelin.wzl

[CP] fix losing slog problem

上级 053d54bc
......@@ -256,7 +256,8 @@ ObStorageLogWriter::ObStorageLogWriter()
file_store_(nullptr),
batch_write_buf_(nullptr),
batch_write_len_(0),
batch_limit_size_(0)
batch_limit_size_(0),
flush_seq_(0)
{}
ObStorageLogWriter::~ObStorageLogWriter()
......@@ -346,6 +347,7 @@ void ObStorageLogWriter::destroy()
batch_write_buf_ = nullptr;
}
batch_write_len_ = 0;
flush_seq_ = 0;
is_started_ = false;
is_inited_ = false;
}
......@@ -365,6 +367,7 @@ int ObStorageLogWriter::start_log(const ObLogCursor& start_cursor)
build_cursor_ = start_cursor;
write_cursor_ = start_cursor;
flush_cursor_ = start_cursor;
flush_seq_ = start_cursor.log_id_;
is_started_ = true;
LOG_INFO("start log", K(start_cursor));
}
......@@ -388,7 +391,7 @@ int ObStorageLogWriter::flush_log(
ObMutexGuard guard(build_log_mutex_);
if (OB_FAIL(get_log_item(cmd, log_buffer, log_item))) {
LOG_WARN("get_log_item failed", K(ret), K(cmd), K(log_buffer));
} else if (OB_FAIL(append_log(*log_item))) {
} else if (OB_FAIL(append_log(*log_item, MAX_APPEND_WAIT_TIME_US))) {
LOG_WARN("append_log failed", K(ret));
}
}
......@@ -964,6 +967,12 @@ int ObStorageLogWriter::sync_log(common::ObIBaseLogItem** items, int64_t& sync_i
DEBUG_SYNC(BEFORE_SLOG_UPDATE_FLUSH_CURSOR);
flush_cursor_ = log_item->end_cursor_;
}
if (OB_UNLIKELY(flush_seq_ != log_item->start_cursor_.log_id_)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("flush_seq_ doesn't match", K(ret), K(flush_seq_), K(log_item->start_cursor_));
} else {
flush_seq_ = log_item->end_cursor_.log_id_;
}
log_item->finish_flush(OB_SUCCESS);
}
const int64_t duration = ObTimeUtility::fast_current_time() - start_ts;
......
......@@ -75,9 +75,10 @@ private:
class ObStorageLogWriter : public common::ObBaseLogWriter {
public:
static const int64_t LOG_FILE_ALIGN_SIZE = 4 * 1024; // 4KB
static const int64_t LOG_BUF_RESERVED_SIZE = 3 * LOG_FILE_ALIGN_SIZE; // NOP + switch_log
static const int64_t LOG_ITEM_MAX_LENGTH = 32 << 20; // 32MB
static const int64_t LOG_FILE_ALIGN_SIZE = 4 * 1024; // 4KB
static const int64_t LOG_BUF_RESERVED_SIZE = 3 * LOG_FILE_ALIGN_SIZE; // NOP + switch_log
static const int64_t LOG_ITEM_MAX_LENGTH = 32 << 20; // 32MB
static const int64_t MAX_APPEND_WAIT_TIME_US = 365 * 24 * 3600 * 1000000L; // 1year
ObStorageLogWriter();
virtual ~ObStorageLogWriter();
......@@ -223,6 +224,7 @@ private:
char *batch_write_buf_;
int64_t batch_write_len_;
int64_t batch_limit_size_;
int64_t flush_seq_;
};
template <typename T>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册