vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.42k stars 2.08k forks source link

Default transaction_mode shows UNSPECIFIED but documentation says MULTI #8150

Closed bolt-leandro closed 7 months ago

bolt-leandro commented 3 years ago

Overview of the Issue

The docs say default is MULTI:

The atomicity policy is controlled by the transaction_mode flag. The default value is multi, and will set it in multi-database mode. https://vitess.io/docs/reference/features/two-phase-commit/#configuring-vtgate

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:

  1. Deploy local example until you have sharded customer keyspace (eg: until step 307_delete_shard_0.sh)

  2. Connect to vtgate and check default _transactionmode

    
    mysql> select @@transaction_mode;
    +--------------------+
    | @@transaction_mode |
    +--------------------+
    | UNSPECIFIED        |
    +--------------------+
    1 row in set (0.00 sec)

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)


#### Binary version
```sh
vagrant@ubuntu-bionic:~/vitess-9.0.0-daa6085/examples/local$ vtgate --version
Version: daa6085 (Git branch 'HEAD') built on Tue Jan 26 09:37:50 UTC 2021 by runner@fv-az195-520 using go1.15.7 linux/amd64

Operating system and Environment details

PaarthAgarwal commented 1 year 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?

hyhuang1218 commented 1 year ago

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)
austenLacy commented 9 months ago

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.

Its-Maniaco commented 8 months ago

@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.