Skip to content
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

RBR based online schema change #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions core/commands/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..lib import constant
from ..lib.error import OSCError
from ..lib.payload.copy import CopyPayload
from ..lib.payload.rbr import RBRPayload

log = logging.getLogger(__name__)

Expand All @@ -34,6 +35,8 @@ class Copy(CommandBase):
NAME = 'copy'

def setup_optional_args(self, parser):
parser.add_argument("--rbr", action='store_true',
help="Use RBR binlogs to catchup")
parser.add_argument("--rebuild", action='store_true',
help="Force an OSC operation even current table "
"already has the desired schema")
Expand Down Expand Up @@ -217,9 +220,14 @@ def validate_args(self):
{'filepath': filepath})

def op(self, sudo=False):
self.payload = CopyPayload(get_conn_func=self.get_conn_func,
sudo=sudo,
**vars(self.args))
if self.args.rbr:
self.payload = RBRPayload(get_conn_func=self.get_conn_func,
sudo=sudo,
**vars(self.args))
else:
self.payload = CopyPayload(get_conn_func=self.get_conn_func,
sudo=sudo,
**vars(self.args))

log.debug("Running schema change")
self.payload.run()
9 changes: 9 additions & 0 deletions core/lib/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ class OSCError(Exception):
'`SHOW CREATE TABLE`. Difference detected: \n {diff}'
)
},
'EMPTY_GTID_SET': {
'code': 150,
'desc': (
'We failed to get a non-empty gtid_set from '
'`START TRANSACTION WITH CONSISTENT SNAPSHOT`. '
'Please make sure that your running MySQL version support '
'GTID'
)
},
'ASSERTION_ERROR': {
'code': 249,
'desc': (
Expand Down
Loading