diff --git a/src/pika_repl_bgworker.cc b/src/pika_repl_bgworker.cc index 05a7915a0..243d9dcaf 100644 --- a/src/pika_repl_bgworker.cc +++ b/src/pika_repl_bgworker.cc @@ -5,13 +5,13 @@ #include -#include "include/pika_repl_bgworker.h" #include "include/pika_cmd_table_manager.h" +#include "include/pika_conf.h" +#include "include/pika_repl_bgworker.h" #include "include/pika_rm.h" #include "include/pika_server.h" #include "pstd/include/pstd_defer.h" #include "src/pstd/include/scope_record_lock.h" -#include "include/pika_conf.h" extern PikaServer* g_pika_server; extern std::unique_ptr g_pika_rm; @@ -97,15 +97,13 @@ void PikaReplBgWorker::HandleBGWorkerWriteBinlog(void* arg) { // because DispatchBinlogRes() have been order them. worker->db_name_ = db_name; - std::shared_ptr db = - g_pika_rm->GetSyncMasterDBByName(DBInfo(db_name)); + std::shared_ptr db = g_pika_rm->GetSyncMasterDBByName(DBInfo(db_name)); if (!db) { LOG(WARNING) << "DB " << db_name << " Not Found"; return; } - std::shared_ptr slave_db = - g_pika_rm->GetSyncSlaveDBByName(DBInfo(db_name)); + std::shared_ptr slave_db = g_pika_rm->GetSyncSlaveDBByName(DBInfo(db_name)); if (!slave_db) { LOG(WARNING) << "Slave DB " << db_name << " Not Found"; return; @@ -121,9 +119,8 @@ void PikaReplBgWorker::HandleBGWorkerWriteBinlog(void* arg) { } if (slave_db->MasterSessionId() != binlog_res.session_id()) { - LOG(WARNING) << "Check SessionId Mismatch: " << slave_db->MasterIp() << ":" - << slave_db->MasterPort() << ", " << slave_db->SyncDBInfo().ToString() - << " expected_session: " << binlog_res.session_id() + LOG(WARNING) << "Check SessionId Mismatch: " << slave_db->MasterIp() << ":" << slave_db->MasterPort() << ", " + << slave_db->SyncDBInfo().ToString() << " expected_session: " << binlog_res.session_id() << ", actual_session:" << slave_db->MasterSessionId(); LOG(WARNING) << "Check Session failed " << binlog_res.slot().db_name(); slave_db->SetReplState(ReplState::kTryConnect); @@ -174,8 +171,8 @@ int PikaReplBgWorker::HandleWriteBinlog(net::RedisParser* parser, const net::Red std::string monitor_message; if (g_pika_server->HasMonitorClients()) { std::string db_name = worker->db_name_.substr(2); - std::string monitor_message = - std::to_string(static_cast(pstd::NowMicros()) / 1000000) + " [" + db_name + " " + worker->ip_port_ + "]"; + std::string monitor_message = std::to_string(static_cast(pstd::NowMicros()) / 1000000) + " [" + db_name + + " " + worker->ip_port_ + "]"; for (const auto& item : argv) { monitor_message += " " + pstd::ToRead(item); } @@ -196,8 +193,7 @@ int PikaReplBgWorker::HandleWriteBinlog(net::RedisParser* parser, const net::Red g_pika_server->UpdateQueryNumAndExecCountDB(worker->db_name_, opt, c_ptr->is_write()); - std::shared_ptr db = - g_pika_rm->GetSyncMasterDBByName(DBInfo(worker->db_name_)); + std::shared_ptr db = g_pika_rm->GetSyncMasterDBByName(DBInfo(worker->db_name_)); if (!db) { LOG(WARNING) << worker->db_name_ << "Not found."; } @@ -225,9 +221,8 @@ void PikaReplBgWorker::WriteDBInSyncWay(const std::shared_ptr& c_ptr) { if (!c_ptr->IsSuspend()) { c_ptr->GetDB()->DBLockShared(); } - if (c_ptr->IsNeedCacheDo() - && PIKA_CACHE_NONE != g_pika_conf->cache_mode() - && c_ptr->GetDB()->cache()->CacheStatus() == PIKA_CACHE_STATUS_OK) { + if (c_ptr->IsNeedCacheDo() && PIKA_CACHE_NONE != g_pika_conf->cache_mode() && + c_ptr->GetDB()->cache()->CacheStatus() == PIKA_CACHE_STATUS_OK) { if (c_ptr->is_write()) { c_ptr->DoThroughDB(); if (c_ptr->IsNeedUpdateCache()) { @@ -243,11 +238,8 @@ void PikaReplBgWorker::WriteDBInSyncWay(const std::shared_ptr& c_ptr) { c_ptr->GetDB()->DBUnlockShared(); } - if (c_ptr->res().ok() - && c_ptr->is_write() - && c_ptr->name() != kCmdNameFlushdb - && c_ptr->name() != kCmdNameFlushall - && c_ptr->name() != kCmdNameExec) { + if (c_ptr->res().ok() && c_ptr->is_write() && c_ptr->name() != kCmdNameFlushdb && c_ptr->name() != kCmdNameFlushall && + c_ptr->name() != kCmdNameExec) { auto table_keys = c_ptr->current_key(); for (auto& key : table_keys) { key = c_ptr->db_name().append(key); @@ -267,7 +259,7 @@ void PikaReplBgWorker::WriteDBInSyncWay(const std::shared_ptr& c_ptr) { if (duration > g_pika_conf->slowlog_slower_than()) { g_pika_server->SlowlogPushEntry(argv, start_time, duration); if (g_pika_conf->slowlog_write_errorlog()) { - LOG(ERROR) << "command: " << argv[0] << ", start_time(s): " << start_time << ", duration(us): " << duration; + LOG(INFO) << "command: " << argv[0] << ", start_time(s): " << start_time << ", duration(us): " << duration; } } }