forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi parts (OpenAtomFoundation#526)
* Update pink support DestConnectFailedHandle func to handle connect failed situation * Update Pink * Add Async Repl Server Binlog Process 1. Add Thread array for writing binlog and writing DB 2. Writing same partition binlog by a preassigned thread in the thread array which assigned by hashing its table+partition 3. Writing same key to DB by a preassigned thread in the thread array which assigned by hashing by its key 4. Add write queue in repl client, all binlog chips will be forwared into that queue first and scheduled to send from the queue later. * Add Repl Client Thread Pool 1. Build a thread pool to process send response. Pb response triggers reading binlog and hadnling binlog and that will block a single thread. Using thread pool instead of single thread will ease that situation. 2. Add rw lock for binlog ctl array in repl clent 3. Add mutex lock for every binlog ctl * Change TrySync MetaSync into async * Debug Binlog Syncing Process 1. Periodically consume write queue to sync binlog to slave using auxiliary thread 2. Trigger sending binlog process using auxiliary thread * Fix Rebase
- Loading branch information
Showing
17 changed files
with
1,000 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2019-present, Qihoo, Inc. All rights reserved. | ||
// This source code is licensed under the BSD-style license found in the | ||
// LICENSE file in the root directory of this source tree. An additional grant | ||
// of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
#ifndef PIKA_REPL_BGWROKER_H_ | ||
#define PIKA_REPL_BGWROKER_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "pink/include/bg_thread.h" | ||
#include "pink/include/pb_conn.h" | ||
|
||
#include "src/pika_inner_message.pb.h" | ||
|
||
#include "include/pika_command.h" | ||
#include "include/pika_binlog_transverter.h" | ||
|
||
class PikaReplBgWorker { | ||
public: | ||
explicit PikaReplBgWorker(int queue_size); | ||
void ScheduleRequest(const std::shared_ptr<InnerMessage::InnerRequest> req, | ||
std::shared_ptr<pink::PbConn> conn, void* req_private_data); | ||
void ScheduleWriteDb(PikaCmdArgsType* argv, BinlogItem* binlog_item, | ||
const std::string table_name, uint32_t partition_id); | ||
int StartThread(); | ||
void QueueSize(int* size_a, int* size_b) { | ||
bg_thread_.QueueSize(size_a, size_b); | ||
} | ||
|
||
static void HandleMetaSyncRequest(void* arg); | ||
static void HandleBinlogSyncRequest(void* arg); | ||
static void HandleTrySyncRequest(void* arg); | ||
static void HandleWriteDb(void* arg); | ||
|
||
BinlogItem binlog_item_; | ||
pink::RedisParser redis_parser_; | ||
std::string ip_port_; | ||
std::string table_name_; | ||
uint32_t partition_id_; | ||
|
||
private: | ||
pink::BGThread bg_thread_; | ||
|
||
static int HandleWriteBinlog(pink::RedisParser* parser, const pink::RedisCmdArgsType& argv); | ||
|
||
struct ReplBgWorkerArg { | ||
const std::shared_ptr<InnerMessage::InnerRequest> req; | ||
std::shared_ptr<pink::PbConn> conn; | ||
void* req_private_data; | ||
PikaReplBgWorker* worker; | ||
ReplBgWorkerArg(const std::shared_ptr<InnerMessage::InnerRequest> _req, std::shared_ptr<pink::PbConn> _conn, void* _req_private_data, PikaReplBgWorker* _worker) : req(_req), conn(_conn), req_private_data(_req_private_data), worker(_worker) { | ||
} | ||
}; | ||
|
||
struct WriteDbBgArg { | ||
PikaCmdArgsType *argv; | ||
BinlogItem* binlog_item; | ||
std::string table_name; | ||
uint32_t partition_id; | ||
WriteDbBgArg(PikaCmdArgsType* _argv, BinlogItem* _binlog_item, const std::string _table_name, uint32_t _partition_id) | ||
: argv(_argv), binlog_item(_binlog_item), table_name(_table_name), partition_id(_partition_id) { | ||
} | ||
~WriteDbBgArg() { | ||
delete argv; | ||
delete binlog_item; | ||
} | ||
}; | ||
}; | ||
|
||
#endif // PIKA_REPL_BGWROKER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.