Skip to content

Support modern replication / binary-log statements (CHANGE REPLICATION SOURCE TO, REPLICA, BINARY LOGS) #25

@kyleconroy

Description

@kyleconroy

Summary

The replication-management vocabulary was renamed across MySQL 8.0.23 → 8.4. The old CHANGE MASTER TO / RESET MASTER / START SLAVE family is removed in 8.4 LTS; the new CHANGE REPLICATION SOURCE TO / RESET BINARY LOGS AND GTIDS / START REPLICA family is now the only accepted form. Marino does not parse most of the new statements.

MySQL versions

  • 8.0.23 — CHANGE REPLICATION SOURCE TO
  • 8.0.22+ — START/STOP/RESET REPLICA
  • 8.2.0 — RESET BINARY LOGS AND GTIDS, SHOW BINARY LOGS, SHOW BINARY LOG STATUS, PURGE BINARY LOGS, DISABLE ON REPLICA for events

Current state in marino

Statement Status
SHOW BINARY LOG STATUS already supported (parser/parser.y:12190-12203)
SHOW REPLICA STATUS already supported (parser/parser.y:12204-12209)
CHANGE REPLICATION SOURCE TO ... not supported
RESET REPLICA [ALL] not supported
START REPLICA / STOP REPLICA not supported
RESET BINARY LOGS AND GTIDS not supported
SHOW BINARY LOGS not supported
PURGE BINARY LOGS BEFORE/TO not supported (only PURGE BACKUP LOGS is at parser.y:6066)
CREATE/ALTER EVENT ... DISABLE ON REPLICA not supported (no disable_on_replica token)

Example SQL

CHANGE REPLICATION SOURCE TO
  SOURCE_HOST    = 'primary.example',
  SOURCE_USER    = 'repl',
  SOURCE_PASSWORD= 'repl_pw',
  SOURCE_PORT    = 3306,
  SOURCE_AUTO_POSITION = 1;
START REPLICA;
STOP REPLICA;
START REPLICA SQL_THREAD UNTIL SQL_AFTER_GTIDS = 'aaa-bbb:1-100';
RESET REPLICA ALL;
SHOW BINARY LOGS;
SHOW BINARY LOG STATUS;
PURGE BINARY LOGS BEFORE '2024-01-01 00:00:00';
PURGE BINARY LOGS TO 'binlog.000123';
RESET BINARY LOGS AND GTIDS;
CREATE EVENT ev_demo
  ON SCHEDULE EVERY 1 HOUR
  DISABLE ON REPLICA
  DO SELECT 1;

ALTER EVENT ev_demo DISABLE ON REPLICA;

Validation

All statements above parse and execute successfully against MySQL 9.2.0 Community.

Notes for the implementer

  • Extend the keywords table with REPLICA, SOURCE, GTIDS, BINLOG (already partial), THREAD, etc., where missing.
  • Add new AST nodes: ChangeReplicationSourceStmt, StartReplicaStmt, StopReplicaStmt, ResetReplicaStmt, ResetBinaryLogsAndGtidsStmt, ShowBinaryLogsStmt, PurgeBinaryLogsStmt. The legacy Slave/Master-named nodes can stay as aliases for compatibility.
  • Add DISABLE ON REPLICA (alongside the existing DISABLE ON SLAVE if any) as a value for the event-status enum.
  • The full option list for CHANGE REPLICATION SOURCE TO is large; mirror the upstream grammar at https://dev.mysql.com/doc/refman/9.2/en/change-replication-source-to.html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions