[MDEV-21921] Make transaction_isolation into a system variable Created: 2020-03-11  Updated: 2023-09-06  Resolved: 2023-04-12

Status: Closed
Project: MariaDB Server
Component/s: Configuration, Variables
Fix Version/s: 11.1.1

Type: Task Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Daniel Black
Resolution: Fixed Votes: 3
Labels: beginner-friendly, gsoc22

Issue Links:
PartOf
is part of MDEV-28906 MySQL 8.0 desired compatibility Open
Problem/Incident
causes MDEV-31746 Problems with tx_isolation after MDEV... Closed
Relates
relates to CONJ-1087 handle mariadb-11.1+ transaction_isol... Open
relates to MDEV-23520 Unknown system variable 'transaction_... Closed
relates to MDEV-31576 Unknown system variable 'transaction_... Closed
relates to MDEV-32109 Compatibility Broken with Mysql JDBC ... Closed

 Description   

In MariaDB, we have a confusing problem where:

  • The transaction_isolation option can be set in a configuration file, but it cannot be set dynamically.
  • The tx_isolation system variable can be set dynamically, but it cannot be set in a configuration file.

Therefore, we have two different names for the same thing in different contexts. This is needlessly confusing, and it complicates the documentation.

MySQL 5.7 solved this problem by making transaction_isolation into a system variable:

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_transaction_isolation

Same has been done to transaction_read_only option:
https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-20.html



 Comments   
Comment by Sergei Golubchik [ 2020-03-27 ]

tx_isolation is a strange name, I agree with GeoffMontee, better to create @@transaction_isolation sysvar, like MySQL did.

We can mark tx_isolation deprecated and remove it eventually.

Comment by Sergei Golubchik [ 2020-05-05 ]

ralf.gebhardt@mariadb.com, no, I would consider it backward compatibility

Comment by Diego Dupin [ 2022-02-15 ]

btw, mysql java driver set transaction_isolation when creating connection, making java connector incompatible with MariaDB:
see https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java#L1211
resulting in error like this one :

java.sql.SQLException: Unknown system variable 'transaction_isolation'
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
	at test.Test.main(Test.java:15)

mysql ODBC use it as well, but only to retrieve isolation level: https://github.com/mysql/mysql-connector-odbc/blob/7f85d3d3e59c30c754570b1a1b47df4b5737e6e2/test/my_tran.c

Comment by Junqi Xie [ 2023-02-12 ]

Hi all! This is my first attempt to create a patch to MariaDB community. https://github.com/MariaDB/server/pull/2491

To implement this feature, I mostly backport the code from MySQL 5.7 branch, noted here. It adds 2 new system variables (transaction_isolation and transaction_read_only) which references the same field as the original variables (tx_isolation and tx_read_only). The original variables are marked as deprecated, and users will get a warning when setting the original variables.

To avoid "surprises" to mariadb developers, I kept the internal representation of these variables. In other words, the change is only visible from a user's perspective. I also updated all the variables referenced in the tests for consistency.

@serg @nikitamalyavin What do you think about this approach and the PR? Thanks in advance.

Comment by Daniel Black [ 2023-04-12 ]

Thank you very much Junqi Xie

Comment by Ian Gilfillan [ 2023-04-12 ]

Thanks junqi_xie for documenting the changes. Note that I reverted and will rework the SET TRANSACTION changes at https://mariadb.com/kb/en/set-transaction/+revision/125221/125173/, as the Knowledge Base is for all maintained versions, currently 10.3+, and the new instructions you specified will not work on releases prior to 11.1

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