-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clone] Persist synchronization gtid from P_S.log_status #1450
Conversation
Hi @sunxiayi! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry for a partial review, but a full review depends on how some of the current comments are going to be resolved.
What is the plan with the two sets of binlog positions, once the mismatch is fixed or its absence is confirmed?
mysql-test/suite/clone/t/local_create_synchronization_coordinates.test
Outdated
Show resolved
Hide resolved
mysql-test/suite/clone/t/local_create_synchronization_coordinates.test
Outdated
Show resolved
Hide resolved
# synchronization_coordinates file contains 4 key/val pairs, only examine 3 Here | ||
# excluding gtid get from binlog_file/offset | ||
|
||
--source include/have_example_plugin.inc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -0,0 +1,104 @@ | |||
# Test after local clone command, synchronization_coordinates file is created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing the tests in rocksdb
suite tests synchronization between binlog and InnoDB. Consider moving it to rocksdb_clone
and adding MyRocks tables too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment still relevant
DROP TABLE t1; | ||
UNINSTALL PLUGIN clone; | ||
--force-rmdir $CLONE_DATADIR | ||
--exec rm -f $MYSQLTEST_VARDIR/tmp/v_local.json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the MTR command, IIIRC remove-file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
plugin/clone/src/clone_client.cc
Outdated
|
||
int Client::set_syncronization_coordinate(const uchar *packet, size_t length) { | ||
Key_Value syncronization_coordinate; | ||
auto err = extract_key_value(packet, length, syncronization_coordinate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto err = extract_key_value(packet, length, syncronization_coordinate); | |
const auto err = extract_key_value(packet, length, syncronization_coordinate); |
plugin/clone/src/clone_client.cc
Outdated
if (err == 0) { | ||
persist_syncronization_coordinate(syncronization_coordinate); | ||
} | ||
return (err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (err); | |
return err; |
plugin/clone/src/clone_client.cc
Outdated
@@ -1962,4 +1982,9 @@ int Client_Cbk::apply_cbk(Ha_clone_file to_file, bool apply_file, | |||
return (err); | |||
} | |||
|
|||
[[nodiscard]] int Client_Cbk::synchronize_engines() { | |||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Remote Clone Client"); | |||
return (ER_NOT_SUPPORTED_YET); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (ER_NOT_SUPPORTED_YET); | |
return ER_NOT_SUPPORTED_YET; |
plugin/clone/src/clone_server.cc
Outdated
} | ||
auto server = get_clone_server(); | ||
if (server->should_send_synchronization_coordinates()) { | ||
for (auto &coordinate : synchronization_coordinates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto &coordinate : synchronization_coordinates) { | |
for (const auto &coordinate : synchronization_coordinates) { |
in the client side, we can reset replica and set global gtid_purged so it can resume replication from that gtid. |
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D55614528
sunxiayi ***@***.***> writes:
What is the plan with the two sets of binlog positions, once the mismatch is fixed or its absence is confirmed?
in the client side, we can reset replica and set global gtid_purged so it can resume replication from that gtid.
Right, but I am asking specifically about the *two sets* of binlog
positions that should be equal: one from pfs.log_status and one from the
binlog itself.
|
If the two sets match, we would use that gtid to resume replication in client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, minor comments only
mysql-test/suite/clone/t/local_create_synchronization_coordinates.test
Outdated
Show resolved
Hide resolved
@@ -17,6 +17,7 @@ | |||
#ifndef CLONE_COMMON_H | |||
#define CLONE_COMMON_H | |||
|
|||
#include "clone.h" | |||
#include "sql/handler.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <string_view>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string_view
for a get_json_object
parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird I can use string_view without declaring the header still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably one of the other headers pulls it in, but
- transitive includes are brittle as the other headers (including standard library ones) may stop including it at any time
- source files and headers should include their dependencies directly - this is also something that tooling like include-what-you-use and clang-tidy enforce
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D55614528
@sunxiayi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary:
Summary
When synchronizing engines, get the synchronization coordinates from P_S.log_status table, send from the server plugin to client plugin. Upon receiving, client plugin writes to a file
#clone/#synchronization_coordinates
.Approach
Protocol
Add a new response type
COM_RES_GTID_V4
and update latest protocol toCLONE_PROTOCOL_VERSION_V4
.Common
synchronize_engines()
call was inHa_clone_common_cbk
. But it actually is only called from server or local, not client. So I move this function into the child class(client, server, local, with client implementation is a no-op). The reason I make this change is because, I want to send the gtid from the plugin layer without calling into engine again, and movingsynchronize_engines()
intoServer_Cbk
has the advantage that I can get the server handler, while inHa_clone_common_cbk
I cannot.The log_status query and set_log_stop steps are moved into a new function
synchronize_logs
underHa_clone_common_cbk
.populate_synchronization_coordinates
would populate a Key_Values data structure of:We want to record both gtid from log_status and from binlog_file/offset because they seem to be out of sync in prod, and need a way to confirm this.
Client
synchronize_engines()
is a no-op and errors out upon calling.Upon receiving
COM_RES_GTID_V4
, deserialize the coordinates and persist that in#clone/#synchronization_coordinates
.Server
synchronize_engines()
would callsynchronize_logs
and get the server handle to send the coordinates one by one, utilizing existing helper functions.Local
synchronize_engines()
would callsynchronize_logs
, then get the client handle to persist coordinates in#clone/#synchronization_coordinates
.Handle version mismatch
In server, only send coordinate if negotiated version >= V4.
In client, #synchronization_coordinates file is cleaned upon start of clone.
Test Plan:
MTR
local_create_synchronization_coordinates
remote_create_synchronization_coordinates
Local clone
Test on my debug build in devserver after
install plugin clone SONAME 'mysql_clone.so';
:1/
mysql> CLONE LOCAL DATA DIRECTORY = '/home/sunxiayi/mysql/mysql-fork/_build-8.0-Debug/mysql-test/var/tmp/mysqld.1/data_new';
2/ Check synchronization coordinate from log_status is the same as in file:
Remote clone, normal
1/ Take udb35350.ftw5:3301 as the test server, install my debug build. Take udb12221.atn5:3301 as the client server, install my debug build. Install plugin on both servers.
2/ On udb12221.atn5:3301, do
3/ Check the new file is written correctly
4/ Repeat the clone, file is overwritten correctly.
Remote clone, sev scenario, apply-logs
Issue a clone command using instance whose mysql.gtid_executed table has hole as donor in the raft world. Also this is copying from secondary to secondary meaning binlog is an apply-logs. Check file on recipient is correct.
Remote clone, donor and client version mismatch
Only update recipient. Clone finishes, file is not there.
Only update donor. Clone finishes, file is not there.
Update both and do a successful clone. Then only update client. File is not there.
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/D55614528