mariadb-corporation / mariadb-connector-r2dbc

Connector for Java R2DBC
Apache License 2.0
115 stars 25 forks source link

Support FOR UPDATE NOWAIT #74

Closed pkgonan closed 8 months ago

pkgonan commented 8 months ago

hello.

I am using Kotlin, Spring Boot, MySQL 8.0.32 and I am using r2dbc-mariadb version 1.1.4.

And I want to handle Pessimistic Lock based on Primary Key without blocking. But currently, it seems that the NOWAIT command does not work when I apply FOR UPDATE NOWAIT.

As expected, different requests should try to acquire the lock for one Primary Key, and requests that fail to acquire the lock should return an error immediately. However, in my tests, the last request is blocked by the thread and waits until the first request finishes before processing it.

If I don't use the R2DBC MariaDB Driver, but instead attach to the database directly and perform the query, the intended behavior works fine. However, when using the R2DBC MariaDB Driver, the intended behavior is not performed.

Are there any plans to support the FOR UPDATE NOWAIT feature?

Example Query select * from gateway_transaction_context where application_id = uuid_to_bin('1ed3f25f-67b7-63c8-a537-2d225963e7b1') and payment_id = uuid_to_bin('1ed70564-e17e-68b2-9c87-8b64836f5061') FOR UPDATE NOWAIT;

pkgonan commented 8 months ago

Hello. @rusher May I ask your advice on the above?

pkgonan commented 8 months ago

Sorry about that.

This is my mistake. It should work fine.