Closed bolt-leandro closed 7 months ago
It would be nice either to fix vtgate default to MULTI or to update the documentation with description of UNSPECIFIED.
Which one of these approaches would you prefer?
It looks like the initial value of @@transaction_mode
is always UNSPECIFIED no matter what is the actual transaction_mode.
In our case, we create vttestserver with option --transaction_mode=SINGLE
. It works as expected, but @@transaction_mode
is still UNSPECIFIED
:
mysql> insert into tags (label, tenant_key, created_at, updated_at) values ('1', '1', '2023-01-01', '2023-01-01'),('2', '2', '2023-01-01', '2023-01-01'),('4', '4', '2023-01-01', '2023-01-01'),('3', '3', '2023-01-01', '2023-01-01'),('11', '11', '2023-01-01', '2023-01-01'),('22', '22', '2023-01-01', '2023-01-01');
ERROR 1317 (70100): multi-db transaction attempted: [target:{keyspace:"test-app-shops" shard:"a0-c0" tablet_type:PRIMARY} transaction_id:1685643362920476910 tablet_alias:{cell:"test" uid:16} target:{keyspace:"test-app-shops" shard:"c0-e0" tablet_type:PRIMARY} transaction_id:1685643363059536837 tablet_alias:{cell:"test" uid:19} target:{keyspace:"test-app-shops" shard:"40-60" tablet_type:PRIMARY} transaction_id:1685643362577274206 tablet_alias:{cell:"test" uid:7} target:{keyspace:"test-app-shops" shard:"80-a0" tablet_type:PRIMA
mysql> select @@transaction_mode;
+--------------------+
| @@transaction_mode |
+--------------------+
| UNSPECIFIED |
+--------------------+
1 row in set (0.00 sec)
I think where this is confusing is that UNSPECIFIED
is returned in relation to the current session and if UNSPECIFIED
then Vitess uses the value provided via the --transaction_mode
vtgate flag as evidenced by @hyhuang1218's comment above.
I think the simplest fix would be for documentation to be updated to mention that UNSPECIFIED
will use the value of transaction_mode
which does appropriately default to MULTI
.
@austenLacy
I tried framing it like this: The atomicity policy is controlled by the transaction_mode flag. If not specified, the default value is UNSPECIFIED
, which itself defaults to MULTI
.
Overview of the Issue
The docs say default is MULTI:
But when I start up cluster and check, it says UNSPECIFIED. This mode is not documented and doesn't correspond to what docs state.
It would be nice either to fix vtgate default to MULTI or to update the documentation with description of UNSPECIFIED.
Reproduction Steps
Steps to reproduce this issue, example:
Deploy local example until you have sharded customer keyspace (eg: until step 307_delete_shard_0.sh)
Connect to vtgate and check default _transactionmode
mysql> set transaction_mode='multi'; Query OK, 0 rows affected (0.00 sec)
mysql> select @@transaction_mode; +--------------------+ | @@transaction_mode | +--------------------+ | MULTI | +--------------------+ 1 row in set (0.00 sec)
Operating system and Environment details
cat /etc/os-release
):uname -sr
):uname -m
):Log Fragments
Not much it seems: