8000 Bug on setting isolation level on r2dbc-mysql · Issue #409 · jasync-sql/jasync-sql · GitHub
[go: up one dir, main page]

Skip to content
Bug on setting isolation level on r2dbc-mysql #409
Closed
@knuclechan

Description

@knuclechan

I've set the transaction isolation level to read commited at postAllocate for the connection.

private Publisher<Void> initIsolationLevel(Connection conn){
		if(conn.getTransactionIsolationLevel() != IsolationLevel.READ_COMMITTED) {
			return conn.setTransactionIsolationLevel(IsolationLevel.READ_COMMITTED);
		}
		return Mono.empty();
	}

According to the documentation, this should be across the lifetime of the connection. But turn out it is not true, the isolation level switch back to repeatable read immediately after the first transaction is run.
This is observed by using select * from performance_schema.events_transactions_current

I look into the source code. On the r2dbc-mysql project,

override fun setTransactionIsolationLevel(isolationLevel: IsolationLevel): Publisher<Void> {
        return executeVoidAfterCurrent("SET TRANSACTION ISOLATION LEVEL ${isolationLevel.asSql()}")
            .doOnSuccess { this.isolationLevel = isolationLevel }
    }

The statement to set the isolation level is not correct. The session keyword should be added to make it effective to all the subsequent transactions. (ref: https://dev.mysql.com/doc/refman/8.0/en/set-transaction.html)
SET SESSION TRANSACTION ISOLATION LEVEL ${isolationLevel.asSql()}

This bug is still there at the master source code
https://github.com/jasync-sql/jasync-sql/blob/master/r2dbc-mysql/src/main/java/JasyncClientConnection.kt

The bug may be also true for other sub-project as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0