From 503bcc0b678c8fa53737838873945f9692caa0f1 Mon Sep 17 00:00:00 2001 From: Frances Thai Date: Tue, 14 May 2024 11:23:17 -0700 Subject: [PATCH 1/2] Add information on how to find starting GTIDs to connector --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ecee39..cbfeffe 100644 --- a/README.md +++ b/README.md @@ -169,4 +169,28 @@ You can start replication from a specific GTID _per keyspace shard_, by setting } ``` -**Note:** When `starting_gtids` is specified in the configuration file, _and_ a `--state` file is passed, the `--state` file will always take precedence. This is so incremental sync continues working. \ No newline at end of file +**Note:** When `starting_gtids` is specified in the configuration file, _and_ a `--state` file is passed, the `--state` file will always take precedence. This is so incremental sync continues working. + +**How to get starting GTIDs** +You can get the latest exectued GTID for every shard by querying your database. +1. Access your PlanetScale database. One way to do so is to use `pscale shell`. +2. Target the keyspace and shard that you would like the latest GTID for by doing `use keyspace/shard`. + - i.e. `use my_sharded_keyspace/-10` + - If your database is _unsharded_, you don't have to target a keyspace or shard. Skip this step. +3. Execute `select @@gtid_executed;` +4. You'll get a result that looks something like: +``` +my_sharded_keyspace/-10> select @@gtid_executed\G +*************************** 1. row *************************** +@@`gtid_executed`: 16cec08d-f91b-11ee-8afb-aacaf4984ae5:1-5639808, +b13c2fe0-f91a-11ee-aa81-6251c27c9c24:1-2487289, +fe8e2a3c-f91a-11ee-9812-82f5834c1ba7:1-46602355 +1 row in set (0.01 sec) +``` +5. Use the GTIDs returned to form the starting GTID for that shard (in this example, shard `-10`): +``` +{"my_sharded_keyspace": {"-10": "MySQL56/16cec08d-f91b-11ee-8afb-aacaf4984ae5:1-5639808,b13c2fe0-f91a-11ee-aa81-6251c27c9c24:1-2487289,fe8e2a3c-f91a-11ee-9812-82f5834c1ba7:1-46602355"}} +``` +6. Repeat this process for all your shards, if your database is sharded. + +**Note**: Remember to prepend the prefix `MySQL56/` onto your starting GTIDs. \ No newline at end of file From 66aae2331493f364871f4ad813270f36dc0e6170 Mon Sep 17 00:00:00 2001 From: Frances Thai Date: Tue, 14 May 2024 11:31:08 -0700 Subject: [PATCH 2/2] Format --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cbfeffe..77a52b4 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ You can start replication from a specific GTID _per keyspace shard_, by setting **Note:** When `starting_gtids` is specified in the configuration file, _and_ a `--state` file is passed, the `--state` file will always take precedence. This is so incremental sync continues working. **How to get starting GTIDs** + You can get the latest exectued GTID for every shard by querying your database. 1. Access your PlanetScale database. One way to do so is to use `pscale shell`. 2. Target the keyspace and shard that you would like the latest GTID for by doing `use keyspace/shard`.