From 41007070b8a37fc81a5b9372f938ea629536da39 Mon Sep 17 00:00:00 2001 From: SanmuWangZJU Date: Thu, 25 Nov 2021 14:13:50 +0800 Subject: [PATCH] [liboblog-ce] adapt modify of oblogmsg --- src/liboblog/src/ob_log_storager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/liboblog/src/ob_log_storager.cpp b/src/liboblog/src/ob_log_storager.cpp index 57bca2a7b1..76aad1950d 100644 --- a/src/liboblog/src/ob_log_storager.cpp +++ b/src/liboblog/src/ob_log_storager.cpp @@ -13,7 +13,7 @@ #define USING_LOG_PREFIX OBLOG #include "lib/string/ob_string.h" // ObString -#include // LogMsgInit, LogMsgDestroy +#include // LogMsgInit, LogMsgDestroy #include // ITableMeta #include "ob_log_storager.h" #include "ob_log_row_data_index.h" // ObLogRowDataIndex @@ -27,6 +27,8 @@ namespace oceanbase namespace liboblog { +static __thread LogMsgBuf *lmb = NULL; + ObLogStorager::ObLogStorager() : inited_(false), round_value_(0), @@ -82,8 +84,6 @@ void ObLogStorager::destroy() const int64_t thread_num = StoragerThread::get_thread_num(); StoragerThread::destroy(); - LogMsgDestroy(); - inited_ = false; round_value_ = 0; destroy_store_buf_array_(thread_num); @@ -149,11 +149,10 @@ int ObLogStorager::push(ObLogEntryTask &task, const int64_t timeout) int ObLogStorager::thread_begin() { int ret = OB_SUCCESS; - int tmp_ret = 0; // First call, initialization required - if (0 != (tmp_ret = LogMsgLocalInit())) { - LOG_ERROR("LogMsgLocalInit fail", K(tmp_ret)); + if (OB_ISNULL(lmb = new LogMsgBuf())) { + LOG_ERROR("LogMsgLocalInit fail"); ret = OB_ERR_UNEXPECTED; } else { LOG_INFO("ObLogStorager LogMsgLocalInit succ"); @@ -165,7 +164,7 @@ int ObLogStorager::thread_begin() void ObLogStorager::thread_end() { // LogMsgLocalDestroy return void - LogMsgLocalDestroy(); + delete lmb; LOG_INFO("ObLogStorager LogMsgLocalDestroy succ"); } @@ -297,7 +296,7 @@ int ObLogStorager::to_string_binlog_record_(ObLogEntryTask &log_entry_task, const int record_type = binlog_record->recordType(); const char *buf = NULL; // Pointer to the first address of the BinlogRecord serialized byte stream size_t buf_len = 0; // Length of BinlogRecord serialised byte stream - buf = binlog_record->toString(&buf_len); + buf = binlog_record->toString(&buf_len, lmb); StoreBuf &store_buf = store_buf_array_[thread_index]; void *ptr = NULL; char *alloc_buf = NULL;