I'm testing some work with MySQL Global Transaction IDs (GTIDs) and I'm having a hard time getting the most-recent session GTID. I've enabled GTIDs (global gtid_mode
is set to ON_PERMISSIVE
). According to the documentation for gtid_owned
:
This read-only variable holds a list whose contents depend on its scope. When used with session scope, the list holds all GTIDs that are owned by this client; ...
So, I expect, after committing a transaction, that this session variable would contain GTIDs; but it is always empty, no matter what I do. However, the global gtid_executed
changes every time I commit a transaction, so I know that GTIDs are working.
Here's a session that demonstrates this issue:
mysql> SELECT @@global.gtid_executed;
| a1c32161-89c4-11e8-856e-0242ac12001d:1-4 |
mysql> SELECT @@session.gtid_next;
| AUTOMATIC |
mysql> SELECT @@session.gtid_owned;
| |
mysql> START TRANSACTION;
mysql> SELECT @@global.gtid_executed;
| a1c32161-89c4-11e8-856e-0242ac12001d:1-4 |
mysql> SELECT @@session.gtid_next;
| AUTOMATIC |
mysql> SELECT @@session.gtid_owned;
| |
mysql> INSERT INTO ........
mysql> SELECT @@global.gtid_executed;
| a1c32161-89c4-11e8-856e-0242ac12001d:1-4 |
mysql> SELECT @@session.gtid_next;
| AUTOMATIC |
mysql> SELECT @@session.gtid_owned;
| |
mysql> COMMIT;
mysql> SELECT @@global.gtid_executed;
| a1c32161-89c4-11e8-856e-0242ac12001d:1-5 |
mysql> SELECT @@session.gtid_next;
| AUTOMATIC |
mysql> SELECT @@session.gtid_owned;
| |
mysql> INSERT INTO ........
mysql> SELECT @@global.gtid_executed;
| a1c32161-89c4-11e8-856e-0242ac12001d:1-6 |
mysql> SELECT @@session.gtid_next;
| AUTOMATIC |
mysql> SELECT @@session.gtid_owned;
| |
Notice that each time a transaction is committed (explicitly or implicitly/autocommit), the global list of executed GTIDs is incremented, but the session gtid_owned
is always empty.
What am I doing wrong/missing? Or have I found a bug?
SELECT @@global.gtid_mode;
->ON_PERMISSIVE
– Generalist