GA

2026/09/25

ALTER DATABASE .. READ ONLY = 1の使いどころ

MySQL 8.0.22とそれ以降で使える ALTER DATABASE .. READ ONLY = 1 、1mysqldプロセスに1スキーマで運用することが多かったのであんまりメリットを感じてなかった( SET GLOBAL super_read_only = ON でいいじゃん ) けどなんか使いどころに出会ったのでメモ。


大前提として、 1mysqldプロセスに1スキーマ でないこと(当たり前)がある。


これ個人的には「ベストプラクティスは1mysqldプロセスに1スキーマ」だと思っていて、その方が権限の管理もやりやすい(MySQLの権限には「グローバルスコープ」「データベース(スキーマ)スコープ」「テーブルスコープ」(ほぼ例外としての「カラムスコープ」)があるけど、 denylistっぽいこと はグローバルスコープを持っている時にしか効かないし、それ以外は allowlistでしか記述できないのでテーブルスコープで列挙するのは(ROLEで楽になったとはいえ)面倒だし自動化しても下手すると事故りそう。グローバルスコープで権限付けるのは論外)し何かあった時の影響範囲も推測しやすいし調べやすい。

ただ、水平シャードを噛ませた時に1プロセス1スキーマでもスキーマ名を分けておくと将来Multi Source Replicationで集約する時にやりやすい(少なくともJOINできるようになるのでPK / UKの重複を観測して手が考えられる。同じスキーマ名だとレプリケーション組んで壊れるまで重複はわからないし、重複していたら試行錯誤のたびにレプリケーションを組み直す必要があって手間) これはチャンネル単位の CHANGE REPLICATION SOURCE TO REPLICATE_REWRITE_DB で解消しているような気がする。


個人の感想は良いとして、こんな論理レプリケーションを使ったアップグレードパスを考えた時に

これまではmysqld単位で SET GLOBAL read_only = ON でバツっと切り替えるしかなかったものが

スキーマ単位でカナリアリリースできるようになる。

レプリケーションの前方互換性があってgtid_mode = ON なら、切り戻す時の手順も全部バツっと切り替える時とそんなに変わらないはず( SET GLOBAL read_only = ? + レプリケーションの逆流だったものが ALTER DATABASE ? READ ONLY = ? に変わるだけで )

なおフツーの read_only とほぼ同じだけどSuper権限でも書き込めず、レプリケーションソースの binlog_format=ROW ならトリガーぶんもちゃんと READ ONLY SCHEMAの中で更新された(FKのCASCADEは試してない)

俺の使用用途には十分な気がする。


【2026/09/25 18:31】

そういえば  information_schema.schemata でREAD ONLYが見えないの不便だなって思ってたけど、

The READ ONLY option, if enabled, is displayed in the INFORMATION_SCHEMA SCHEMATA_EXTENSIONS table. See Section 28.3.32, “The INFORMATION_SCHEMA SCHEMATA_EXTENSIONS Table”.

https://dev.mysql.com/doc/refman/8.4/en/alter-database.html#alter-database-read-only

危うくFeature Requestを出してしまうところだった… 



2026/09/04

InnoDBのCHECK TABLEが何をやっているのかざっと見てみたメモ

MySQL 8.0.46 ベースに見ていく。

まずは俺の好きな sql/sql_yacc.yy からダイブ。 CHECK TABLE の定義はこのへん。

 9627 check_table_stmt:
 9628           CHECK_SYM table_or_tables table_list opt_mi_check_types
 9629           {
 9630             $$= NEW_PTN PT_check_table_stmt(YYMEM_ROOT, $3,
 9631                                             $4.flags, $4.sql_flags);
 9632           }
 9633         ;
 9634
 9635 opt_mi_check_types:
 9636           %empty { $$.flags = T_MEDIUM; $$.sql_flags= 0; }
 9637         | mi_check_types
 9638         ;
 9639
 9640 mi_check_types:
 9641           mi_check_type
 9642         | mi_check_type mi_check_types
 9643           {
 9644             $$.flags= $1.flags | $2.flags;
 9645             $$.sql_flags= $1.sql_flags | $2.sql_flags;
 9646           }
 9647         ;
 9648
 9649 mi_check_type:
 9650           QUICK
 9651           { $$.flags= T_QUICK;              $$.sql_flags= 0; }
 9652         | FAST_SYM
 9653           { $$.flags= T_FAST;               $$.sql_flags= 0; }
 9654         | MEDIUM_SYM
 9655           { $$.flags= T_MEDIUM;             $$.sql_flags= 0; }
 9656         | EXTENDED_SYM
 9657           { $$.flags= T_EXTEND;             $$.sql_flags= 0; }
 9658         | CHANGED
 9659           { $$.flags= T_CHECK_ONLY_CHANGED; $$.sql_flags= 0; }
 9660         | FOR_SYM UPGRADE_SYM
 9661           { $$.flags= 0;                    $$.sql_flags= TT_FOR_UPGRADE; }
 9662         ;

フラグの定数名が分かるくらいなのでさっさと PT_check_table_stmt に飛ぶ。

3211 Sql_cmd *PT_check_table_stmt::make_cmd(THD *thd) {
3212   thd->lex->sql_command = SQLCOM_CHECK;
3213
3214   LEX *const lex = thd->lex;
3215   Query_block *const select = lex->current_query_block();
3216
3217   if (lex->sphead) {
3218     my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK");
3219     return nullptr;
3220   }
3221
3222   lex->check_opt.flags |= m_flags;
3223   lex->check_opt.sql_flags |= m_sql_flags;
3224   if (select->add_tables(thd, m_table_list, TL_OPTION_UPDATING, TL_UNLOCK,
3225                          MDL_SHARED_READ))
3226     return nullptr;
3227
3228   thd->lex->alter_info = &m_alter_info;
3229   return new (thd->mem_root) Sql_cmd_check_table(&m_alter_info);
3230 }

Sql_cmd_check_table に飛ぶ。

1755 bool Sql_cmd_check_table::execute(THD *thd) {
1756   Table_ref *first_table = thd->lex->query_block->get_table_list();
1757   thr_lock_type lock_type = TL_READ_NO_INSERT;
1758   bool res = true;
1759   DBUG_TRACE;
1760
1761   if (check_table_access(thd, SELECT_ACL, first_table, true, UINT_MAX, false))
1762     goto error; /* purecov: inspected */
1763   thd->enable_slow_log = opt_log_slow_admin_statements;
1764
1765   res = mysql_admin_table(thd, first_table, &thd->lex->check_opt, "check",
1766                           lock_type, false, false, HA_OPEN_FOR_REPAIR, nullptr,
1767                           &handler::ha_check, 1, m_alter_info, true);
1768
1769   thd->lex->query_block->m_table_list.first = first_table;
1770   thd->lex->query_tables = first_table;
1771
1772 error:
1773   return res;
1774 }

mysql_admin_table に飛ぶ。この時、10番目の引数が handler::ha_check になっているので

 693 /*
 694   RETURN VALUES
 695     false Message sent to net (admin operation went ok)
 696     true  Message should be sent by caller
 697           (admin operation or network communication failed)
 698 */
 699 static bool mysql_admin_table(
 700     THD *thd, Table_ref *tables, HA_CHECK_OPT *check_opt,
 701     const char *operator_name, thr_lock_type lock_type, bool open_for_modify,
 702     bool repair_table_use_frm, uint extra_open_options,
 703     int (*prepare_func)(THD *, Table_ref *, HA_CHECK_OPT *),
 704     int (handler::*operator_func)(THD *, HA_CHECK_OPT *), int check_view,
 705     Alter_info *alter_info, bool need_to_acquire_shared_backup_lock) {

案の定 mysql_admin_table 側では int (handler::*operator_func)(THD *, HA_CHECK_OPT *) として受け取られていて

1107     if (check_opt && (check_opt->sql_flags & TT_FOR_UPGRADE) != 0) {
1108       if (table->table->s->tmp_table) {
1109         result_code = HA_ADMIN_OK;
1110       } else {
1111         dd::String_type snam = dd::make_string_type(table->table->s->db);
1112         dd::String_type tnam =
1113             dd::make_string_type(table->table->s->table_name);
1114
1115         Check_result cr = check_for_upgrade(thd, snam, tnam, [&]() {
1116           DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name));
1117           return (table->table->file->*operator_func)(thd, check_opt);
1118         });
1119
1120         result_code = cr.second;
1121         if (cr.first) {
1122           goto err;
1123         }
1124       }
1125     }
1126     // Some other admin COMMAND
1127     else {
1128       DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name));
1129       result_code = (table->table->file->*operator_func)(thd, check_opt);
1130     }
1131     DBUG_PRINT("admin", ("operator_func returned: %d", result_code));

まあ結局 handler::ha_check を叩くことになる。

4680 int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt) {
4681   int error;
4682   assert(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK);
4683
4684   if ((table->s->mysql_version >= MYSQL_VERSION_ID) &&
4685       (check_opt->sql_flags & TT_FOR_UPGRADE))
4686     return 0;
4687
4688   if (table->s->mysql_version < MYSQL_VERSION_ID) {
4689     // Check for old temporal format if avoid_temporal_upgrade is disabled.
4690     mysql_mutex_lock(&LOCK_global_system_variables);
4691     const bool check_temporal_upgrade = !avoid_temporal_upgrade;
4692     mysql_mutex_unlock(&LOCK_global_system_variables);
4693
4694     if ((error = check_table_for_old_types(table, check_temporal_upgrade)))
4695       return error;
4696     error = ha_check_for_upgrade(check_opt);
4697     if (error && (error != HA_ADMIN_NEEDS_CHECK)) return error;
4698     if (!error && (check_opt->sql_flags & TT_FOR_UPGRADE)) return 0;
4699   }
4700   return check(thd, check_opt);
4701 }

これは結局ストレージエンジン層の check メソッドを呼ぶので

$ grep 'int check(' storage/ -r
storage/archive/ha_archive.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/csv/ha_tina.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/innobase/handler/ha_innodb.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/innobase/handler/ha_innopart.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/myisam/ha_myisam.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/myisammrg/ha_myisammrg.h:  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
storage/temptable/include/temptable/handler.h:  int check(THD *, HA_CHECK_OPT *) override;

こう分かれていて、まあ興味があるのはInnoDBなので storage/innobase/handler/ha_innodb.h から辿っていく。

18152 /** Tries to check that an InnoDB table is not corrupted. If corruption is
18153  noticed, prints to stderr information about it. In case of corruption
18154  may also assert a failure and crash the server.
18155  @return HA_ADMIN_CORRUPT or HA_ADMIN_OK */
18156
18157 int ha_innobase::check(THD *thd,                /*!< in: user thread handle */
18158                        HA_CHECK_OPT *check_opt) /*!< in: check options */
18159 {

一応ここまで check_opt は引き回され続けてはいる。

18218   for (index = m_prebuilt->table->first_index(); index != nullptr;
18219        index = index->next()) {
18220     /* If this is an index being created or dropped, skip */
18221     if (!index->is_committed()) {
18222       continue;
18223     }

このループから、フラグと言うか修飾子というかによらずセカンダリインデックスも範囲なんだってことはわかった。

18225     if (!(check_opt->flags & T_QUICK) && !index->is_corrupted()) {
18226       /* Enlarge the fatal lock wait timeout during
18227       CHECK TABLE. */
18228       srv_fatal_semaphore_wait_extend.fetch_add(1);
18229
18230       bool valid = btr_validate_index(index, m_prebuilt->trx, false);
18231
18232       /* Restore the fatal lock wait timeout after
18233       CHECK TABLE. */
18234       srv_fatal_semaphore_wait_extend.fetch_sub(1);
18235
18236       if (!valid) {
18237         is_ok = false;
18238
18239         push_warning_printf(thd, Sql_condition::SL_WARNING, ER_NOT_KEYFILE,
18240                             "InnoDB: The B-tree of"
18241                             " index %s is corrupted.",
18242                             index->name());
18243         continue;
18244       }
18245     }

CHECK TABLE .. QUICK でない場合は btr_validate_index に入る。

18281     size_t max_threads = thd_parallel_read_threads(m_prebuilt->trx->mysql_thd);
18282
18283     /* Scan this index. */
18284     if (dict_index_is_spatial(index)) {
18285       ret = row_count_rtree_recs(m_prebuilt, &n_rows, &n_dups);
18286       if ((check_opt->flags & T_EXTEND) && (ret == DB_SUCCESS) &&
18287           !(n_rows < n_rows_in_table || n_dups < n_rows - n_rows_in_table)) {
18288         /* For CHECK TABLE EXTENDED; we also want to make sure that MBR stored
18289         in SPATIAL Index is matching the MBR of geometry stored in Clustered
18290         record. */
18291         m_prebuilt->need_to_access_clustered = true;
18292         n_rows = 0;
18293         n_dups = 0;
18294         ret = row_count_rtree_recs(m_prebuilt, &n_rows, &n_dups);
18295       }
18296     } else {
18297       ret = row_scan_index_for_mysql(m_prebuilt, index, max_threads, true,
18298                                      &n_rows);
18299     }

パラレルでやるっぽいことと、空間インデックスは CHECK TABLE .. EXTEND の時だけ舐めることが分かった。

18309     if (ret == DB_INTERRUPTED || thd_killed(m_user_thd)) {
18310       /* Do not report error since this could happen
18311       during shutdown */
18312       break;
18313     }
18314     if (ret != DB_SUCCESS) {
18315       /* Assume some kind of corruption. */
18316       push_warning_printf(thd, Sql_condition::SL_WARNING, ER_NOT_KEYFILE,
18317                           "InnoDB: The B-tree of"
18318                           " index %s is corrupted.",
18319                           index->name());
18320       is_ok = false;
18321       dict_set_corrupted(index);
18322     }
18323
18324     if (index == m_prebuilt->table->first_index()) {
18325       n_rows_in_table = n_rows;
18326     } else if (!(index->type & DICT_FTS) && (n_rows != n_rows_in_table) &&
18327                (!index->is_multi_value()) &&
18328                (!dict_index_is_spatial(index) || (n_rows < n_rows_in_table) ||
18329                 (n_dups < n_rows - n_rows_in_table))) {
18330       push_warning_printf(thd, Sql_condition::SL_WARNING, ER_NOT_KEYFILE,
18331                           "InnoDB: Index '%-.200s' contains %lu"
18332                           " entries, should be %lu.",
18333                           index->name(), (ulong)n_rows, (ulong)n_rows_in_table);
18334       is_ok = false;
18335       dict_set_corrupted(index);
18336     }
18337   }

row_scan_index_for_mysql の結果でメッセージなど出し分けつつ、18337行目がインデックスのforループの終端。あとは結果を返すだけ。

ということで結論。

  • データ行(クラスタインデックス) だけじゃなくてセカンダリキーもちゃんと見る
  • 空間インデックスがある時は CHECK TABLE .. EXTEND で空間インデックスも見る
  • CHECK TABLE .. QUICK の時にかっ飛ばす処理は btr_validate_index だけだけどこれが結構速くなる上に全部のインデックスを読むには読むので、地味にバッファプールをあっためられる( SELECT /*+ INDEX(t PRIMARY) */ COUNT(*) FROM t をインデックスごとにループさせるのとそんな時間変わらない )
​

2026/08/25

ALTER TABLEがMetadata Lockで詰まらされた時に検知する何か

TL;DR

  • yt-mdl-checker というスクリプトを書いた
  • performance_schema.metadata_locks から PENDING になっている EXCLUSIVE なロックを引いて、同じテーブルで既に GRANTED になっているやつを KILL するスクリプト
  • クエリ自体は大したことないので、わざわざスクリプト使わなくてもスニペットとして使えるはず

主に「 ALTER TABLE 流したらオンラインALTER TABLEのはずなのに刺さった」対策。たとえ SELECT でも、一度でもそのテーブルに触って COMMIT されていないトランザクションがあれば、その共有MDLが ALTER TABLE の排他MDLをブロックしてしまって、その後のクエリが共有MDLを取れなくなって連鎖的にやられていくケース。

ALTER TABLE 開始時の排他MDLに刺さったらCtrl+Cすればいいだけだけど、オンラインALTER TABLEは一度共有MDLにフォールバックした後 ALTER TABLE 終了処理の中でもう一度排他MDLを取ろうとするので、後者を止めるのは難しい(ずっと張り付いてられるくらいの時間なら張り付いていればいいだけだけれども)ので、なんかALTER TABLEとセットで流せる奴があるといいなとか思った。

使い方は mysql コマンドラインクライアントと似たようなオプションで

$ yt-mdl-checker -hlocalhost -uroot -p'xxx' -i 3 --kill

とかやっておけば、3秒おきにチェックして勝手に KILL してくれそうな感じにしてある。
READMEも書いてます。

https://github.com/yoku0825/ytkit/blob/9b4af50b98b6a16b8f44f084d7220e32a4290c63/README.md#L571-L662

​

2026/06/26

Group ReplicationでのExecuted_Gtid_Setの進み方

TL;DR

  • たとえシングルプライマリモードだろうと、GTIDは「そのマシンが使うレンジ」が先に割り当てられて、その中からGTIDを払い出していく
  • 元プライマリが使っていたGTIDレンジは、割り当てられたレンジが使い切られない限り、再びプライマリに戻った時に再利用する。

yt-sandbox ってやつでグループレプリケーション環境のコンテナが簡単に立ち上げられるらしいよ(ステマ)

$ yt-sandbox -t gr 8.4
[2816233] NOTE: Generate Sandbox directry into /home/yoku0825/yt-sandbox/golf
[2816233] NOTE: Node1 Container Ipaddress: 172.17.0.2
[2816233] NOTE: Node2 Container Ipaddress: 172.17.0.3
[2816233] NOTE: Node3 Container Ipaddress: 172.17.0.4
Sandbox deployed into /home/yoku0825/yt-sandbox/golf

$ cd /home/yoku0825/yt-sandbox/golf

$ ll
total 28
-rwxr-xr-x. 1 yoku0825 yoku0825 485 Jun 26 08:26 check_group_replication
-rw-r--r--. 1 yoku0825 yoku0825  97 Jun 26 08:26 destroy_all
-rw-r--r--. 1 yoku0825 yoku0825  54 Jun 26 08:26 hosts
lrwxrwxrwx. 1 yoku0825 yoku0825  40 Jun 26 08:26 m -> /home/yoku0825/yt-sandbox/golf/node1/use
drwxr-xr-x. 3 yoku0825 yoku0825 101 Jun 26 08:26 node1
drwxr-xr-x. 3 yoku0825 yoku0825 101 Jun 26 08:26 node2
drwxr-xr-x. 3 yoku0825 yoku0825 101 Jun 26 08:26 node3
-rwxr-xr-x. 1 yoku0825 yoku0825  97 Jun 26 08:26 restart_all
lrwxrwxrwx. 1 yoku0825 yoku0825  40 Jun 26 08:26 s1 -> /home/yoku0825/yt-sandbox/golf/node2/use
lrwxrwxrwx. 1 yoku0825 yoku0825  40 Jun 26 08:26 s2 -> /home/yoku0825/yt-sandbox/golf/node3/use
-rwxr-xr-x. 1 yoku0825 yoku0825  95 Jun 26 08:26 start_all
-rwxr-xr-x. 1 yoku0825 yoku0825  94 Jun 26 08:26 stop_all
-rwxr-xr-x. 1 yoku0825 yoku0825  93 Jun 26 08:26 use_all

シングルプライマリーで上がってくるので、1号機に接続して操作。

$ ./m
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 8.4.9 MySQL Community Server - GPL

Copyright (c) 2000, 2026, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

golf-1> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000001 |      158 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

golf-1> create database d1;
Query OK, 1 row affected (0.01 sec)

golf-1> create table d1.t1 (num serial, val varchar(32));
Query OK, 0 rows affected (0.02 sec)

golf-1> INSERT INTO d1.t1 VALUES (1, 'one');
Query OK, 1 row affected (0.00 sec)

golf-1>
golf-1>
golf-1> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                        |
+---------------+----------+--------------+------------------+------------------------------------------+
| binlog.000001 |      848 |              |                  | 01234567-89ab-cdef-0123-456789abcdef:1-3 |
+---------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)

golf-1> ^DBye

2号機をプライマリーにして書き込み。
100万番単位でGTIDが割り振られるっぽく、100万飛んで1のGTIDが振られる。

【2026/06/26 18:31】
レンジの大きさは group_replication_gtid_assignment_block_size デフォルト100万で決められる。
$ ./s1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.4.9 MySQL Community Server - GPL

Copyright (c) 2000, 2026, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

golf-2> SELECT group_replication_set_as_primary(@@server_uuid);
+------------------------------------------------------------------+
| group_replication_set_as_primary(@@server_uuid)                  |
+------------------------------------------------------------------+
| Primary server switched to: b91f989d-7138-11f1-aa86-0242ac110003 |
+------------------------------------------------------------------+
1 row in set (0.00 sec)

golf-2>
golf-2> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                        |
+---------------+----------+--------------+------------------+------------------------------------------+
| binlog.000001 |      845 |              |                  | 01234567-89ab-cdef-0123-456789abcdef:1-3 |
+---------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)

golf-2>
golf-2> INSERT INTO d1.t1 VALUES (3, 'three');
Query OK, 1 row affected (0.00 sec)

golf-2>
golf-2> SELECT * FROM d1.t1;
+-----+-------+
| num | val   |
+-----+-------+
|   1 | one   |
|   3 | three |
+-----+-------+
2 rows in set (0.01 sec)

golf-2>
golf-2> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+--------------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                                |
+---------------+----------+--------------+------------------+--------------------------------------------------+
| binlog.000001 |     1137 |              |                  | 01234567-89ab-cdef-0123-456789abcdef:1-3:1000001 |
+---------------+----------+--------------+------------------+--------------------------------------------------+
1 row in set (0.00 sec)

1号機にプライマリーを戻して書くと、3の次の4が使い回される。

$ ./m
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 8.4.9 MySQL Community Server - GPL

Copyright (c) 2000, 2026, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

golf-1> SELECT group_replication_set_as_primary(@@server_uuid);
+------------------------------------------------------------------+
| group_replication_set_as_primary(@@server_uuid)                  |
+------------------------------------------------------------------+
| Primary server switched to: b24cf04e-7138-11f1-b6c3-0242ac110002 |
+------------------------------------------------------------------+
1 row in set (0.00 sec)

golf-1>
golf-1> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+--------------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                                |
+---------------+----------+--------------+------------------+--------------------------------------------------+
| binlog.000001 |     1137 |              |                  | 01234567-89ab-cdef-0123-456789abcdef:1-3:1000001 |
+---------------+----------+--------------+------------------+--------------------------------------------------+
1 row in set (0.00 sec)

golf-1>
golf-1> INSERT INTO d1.t1 VALUES (4, 'four');
Query OK, 1 row affected (0.00 sec)

golf-1>
golf-1> SHOW BINARY LOG STATUS;
+---------------+----------+--------------+------------------+--------------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                                |
+---------------+----------+--------------+------------------+--------------------------------------------------+
| binlog.000001 |     1428 |              |                  | 01234567-89ab-cdef-0123-456789abcdef:1-4:1000001 |
+---------------+----------+--------------+------------------+--------------------------------------------------+
1 row in set (0.00 sec)

マルチプライマリなら疑問に思うこともないくらい自然な動作だし、シングルプライマリーでも super_read_only 外したら書けちゃうくらいなので、そのへんの動作は一緒なのであろう。

​