forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Almost a direct port of the feature in 5.6 except for minor visual changes and some minor changes related to 8.0 thread handling Also brings in the basic raft_listener_queue without the implemented functions Differential Revision: D21670710 Use DBUG_TRACE instead of DBUG_ENTER Summary: several testcase failed in asan debug, ==106552==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7f38f3590078 at pc 0x0000093aa495 bp 0x7f38f358ffc0 sp 0x7f38f358ffb8 READ of size 4 at 0x7f38f3590078 thread T203 #0 0x93aa494 in _db_enter_(char const*, int, char const*, unsigned int, _db_stack_frame_*) #1 0x8d0b9bb in Relay_log_info::remove_logged_gtids #2 0x8b1ec3f in trim_logged_gtid #3 0x8c767cf in process_raft_queue If Use DBUG_ENTER, then you need to use DBUG_RETURN to pop current frame in CODE_STATE. If use DBUG_TRACE, it will pop current frame during .dtor ps. small refactor changes for sql/rpl_handler.cc Reviewed By: bhatvinay Differential Revision: D28809418
- Loading branch information
Showing
6 changed files
with
560 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <future> | ||
#include <map> | ||
#include <vector> | ||
|
||
/* Type of callback that raft plugin wants to invoke in the server */ | ||
enum class RaftListenerCallbackType { | ||
SET_READ_ONLY = 1, | ||
UNSET_READ_ONLY = 2, | ||
TRIM_LOGGED_GTIDS = 3, | ||
ROTATE_BINLOG = 4, | ||
ROTATE_RELAYLOG = 5, | ||
RAFT_LISTENER_THREADS_EXIT = 6, | ||
RLI_RELAY_LOG_RESET = 7, | ||
RESET_SLAVE = 8, | ||
BINLOG_CHANGE_TO_APPLY = 9, | ||
BINLOG_CHANGE_TO_BINLOG = 10, | ||
STOP_SQL_THREAD = 11, | ||
START_SQL_THREAD = 12, | ||
STOP_IO_THREAD = 13, | ||
CHANGE_MASTER = 14, | ||
GET_COMMITTED_GTIDS = 15, | ||
GET_EXECUTED_GTIDS = 16, | ||
SET_BINLOG_DURABILITY = 17, | ||
}; | ||
|
||
/* Callback argument, each type would just populate the fields needed for its | ||
* callback */ | ||
class RaftListenerCallbackArg { | ||
public: | ||
explicit RaftListenerCallbackArg() {} | ||
|
||
std::vector<std::string> trim_gtids = {}; | ||
std::pair<std::string, unsigned long long> log_file_pos = {}; | ||
bool val_bool; | ||
uint32_t val_uint; | ||
std::pair<std::string, unsigned int> master_instance; | ||
std::string val_str; | ||
std::map<std::string, unsigned int> val_sys_var_uint; | ||
}; | ||
|
||
/* Result of the callback execution in the server. This will be set in the | ||
* future's promise (in the QueueElement) and the invoker can get()/wait() for | ||
* the result. Add more fields as needed */ | ||
class RaftListenerCallbackResult { | ||
public: | ||
explicit RaftListenerCallbackResult() {} | ||
|
||
// Indicates if the callback was able to execute successfully | ||
int error = 0; | ||
std::vector<std::string> gtids; | ||
std::string val_str; | ||
}; | ||
|
||
class RaftListenerQueueIf { | ||
public: | ||
static const int RAFT_FLAGS_POSTAPPEND = 1; | ||
static const int RAFT_FLAGS_NOOP = 2; | ||
|
||
virtual ~RaftListenerQueueIf() {} | ||
|
||
/* Defines the element of the queue. It consists of the callback type to be | ||
* invoked and the argument (optional) for the callback */ | ||
struct QueueElement { | ||
// Type of the callback to invoke in the server | ||
RaftListenerCallbackType type; | ||
|
||
// Argument to the callback | ||
RaftListenerCallbackArg arg; | ||
|
||
/* result of the callback will be fulfilled through this promise. If this | ||
* is set, then the invoker should ensure tht he eventually calls | ||
* get()/wait() to retrieve the result. Example: | ||
* | ||
* std::promise<RaftListenerCallbackResult> promise; | ||
* std::future<RaftListenerCallbackResult> fut = promise.get_future(); | ||
* | ||
* QueueElement e; | ||
* e.type = RaftListenerCallbackType::SET_READ_ONLY; | ||
* e.result = &promise; | ||
* listener_queue.add(std::move(e)); | ||
* .... | ||
* .... | ||
* .... | ||
* // Get the result when we want it. This wll block until the promise is | ||
* // fullfilled by the raft listener thread after executing the callback | ||
* RaftListenerCallbackResult result = fut.get(); | ||
*/ | ||
std::promise<RaftListenerCallbackResult> *result = nullptr; | ||
}; | ||
|
||
/* Add an element to the queue. This will signal any listening threads | ||
* after adding the element to the queue | ||
* | ||
* @param element QueueElement to add to queue | ||
* | ||
* @return 0 on success, 1 on error | ||
*/ | ||
virtual int add(QueueElement element) = 0; | ||
|
||
/* Get an element from the queue. This will block if there are no elements | ||
* in the queue to be processed | ||
* | ||
* @return QueueElement to be processed next | ||
*/ | ||
virtual QueueElement get() = 0; | ||
|
||
virtual void deinit() = 0; | ||
}; |
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.