[MDEV-23579] set transaction 's next tranasction only mode isn't obvservable in @@session.tx_read_only Created: 2020-08-25  Updated: 2020-09-25

Status: Open
Project: MariaDB Server
Component/s: Documentation
Affects Version/s: 10.1.47, 10.5.6
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Ian Gilfillan
Resolution: Unresolved Votes: 0
Labels: None


 Description   

MariaDB [test]> create table test (i int auto_increment primary key);
Query OK, 0 rows affected (0.002 sec)
 
MariaDB [test]> start transaction read only;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> insert into t() values ();
ERROR 1792 (25006): Cannot execute statement in a READ ONLY transaction
MariaDB [test]> select @@tx_read_only;
+----------------+
| @@tx_read_only |
+----------------+
|              0 |
+----------------+
1 row in set (0.000 sec)
 
MariaDB [test]> SELECT @@GLOBAL.tx_read_only, @@SESSION.tx_read_only;
+-----------------------+------------------------+
| @@GLOBAL.tx_read_only | @@SESSION.tx_read_only |
+-----------------------+------------------------+
|                     0 |                      0 |
+-----------------------+------------------------+
1 row in set (0.000 sec)
 
MariaDB [test]> rollback;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> start transaction
    -> ;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> SET TRANSACTION READ ONLY;
ERROR 1568 (25001): Transaction characteristics can't be changed while a transaction is in progress
MariaDB [test]> rollback;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> SET TRANSACTION READ ONLY;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> start transaction;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> SELECT @@GLOBAL.tx_read_only, @@SESSION.tx_read_only;
+-----------------------+------------------------+
| @@GLOBAL.tx_read_only | @@SESSION.tx_read_only |
+-----------------------+------------------------+
|                     0 |                      0 |
+-----------------------+------------------------+
1 row in set (0.000 sec)
MariaDB [test]> select version();
+--------------------+
| version()          |
+--------------------+
| 10.5.6-MariaDB-log |
+--------------------+
1 row in set (0.000 sec)



 Comments   
Comment by Daniel Black [ 2020-08-25 ]

10.1.47

MariaDB [test]>  start transaction read only;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]>  insert into t() values ();
ERROR 1792 (25006): Cannot execute statement in a READ ONLY transaction.
MariaDB [test]> SELECT @@GLOBAL.tx_read_only, @@SESSION.tx_read_only;
+-----------------------+------------------------+
| @@GLOBAL.tx_read_only | @@SESSION.tx_read_only |
+-----------------------+------------------------+
|                     0 |                      0 |
+-----------------------+------------------------+
1 row in set (0.000 sec)
 
MariaDB [test]> rollback;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> SET TRANSACTION READ ONLY;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]>  start transaction;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]>  SELECT @@GLOBAL.tx_read_only, @@SESSION.tx_read_only;
+-----------------------+------------------------+
| @@GLOBAL.tx_read_only | @@SESSION.tx_read_only |
+-----------------------+------------------------+
|                     0 |                      0 |
+-----------------------+------------------------+
1 row in set (0.000 sec)
 
MariaDB [test]>  select version();
+-----------------+
| version()       |
+-----------------+
| 10.1.47-MariaDB |
+-----------------+
1 row in set (0.000 sec)

Comment by Daniel Black [ 2020-08-26 ]

MariaDB [(none)]> set session  TRANSACTION READ ONLY;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [(none)]> SELECT @@GLOBAL.tx_read_only, @@SESSION.tx_read_only;
+-----------------------+------------------------+
| @@GLOBAL.tx_read_only | @@SESSION.tx_read_only |
+-----------------------+------------------------+
|                     0 |                      1 |
+-----------------------+------------------------+

So it pulls the session tx_read_only, but not the "next transaction" status of read only.

greenman does this need clarity https://mariadb.com/kb/en/set-transaction/ (Access Mode)

Comment by Daniel Black [ 2020-08-27 ]

https://mariadb.com/kb/en/start-transaction/
"READ WRITE and READ ONLY can also be specified in the SET TRANSACTION statement, in which case the specified mode is valid for all sessions, or for all subsequent transaction used by the current session."

`set transaction` as 3 modes, global, next transaction, and all subsequent in session.

An assumption that without global, its session was made,where its only subsequent

Generated at Thu Feb 08 09:23:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.