Open Tiikara opened 1 year ago
Can you please create a small reproducer and share it on a public git repo? Ideally with testcontainers for the db setup
I'll try to make time for that next week
it would be good also for the reproducer to be in java and avoid kotlin
I tried to reproduce the error, but in pure Java the system doesn't hang on commit. Unfortunately, I could not get the same behavior as in Kotlin. But nevertheless, after rolling back a checkpoint, the transaction is not committed, but the transaction is rolled back.
Because after the checkpoint rollback the transaction must be valid and the transaction commit must be allowed.
There are no plans to implement such behavior in the future?
withConnection: START
query("INSERT INTO users (name) VALUES ('test')"): START
query("INSERT INTO users (name) VALUES ('test')"): SUCCESS
query("SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): START
query("SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): SUCCESS
query("INSERT INTO users (name) VALUES ('test')"): START
query("INSERT INTO users (name) VALUES ('test')"): FAIL. That was planned fail on unique index: ERROR: duplicate key value violates unique constraint "users_name_key" (23505)
Now we should rollback savepoint and commit transaction
query("ROLLBACK TO SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): START
query("ROLLBACK TO SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): SUCCESS
query("RELEASE SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): START
query("RELEASE SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): SUCCESS
commit(): START
commit(): FAIL: io.vertx.sqlclient.TransactionRollbackException: Rollback
query("RELEASE SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): FAIL: Rollback
query("ROLLBACK TO SAVEPOINT AsyncSqlConnectionPgSavepointWithErrorHandling"): FAIL: Rollback
begin: FAIL: io.vertx.sqlclient.TransactionRollbackException: Rollback
withConnection: FAIL: io.vertx.sqlclient.TransactionRollbackException: Rollback
Questions
I have encountered some strange transaction behaviour. If I execute a query after the transaction starts, create a checkpoint, then this query terminates with an exception (in my case an index constraint error). Then I rollback the checkpoint, and after that when commit transaction the system hangs. At the same time rollback works. In Debug I saw that there is a flag failed in the transaction object. Is this how it should be or am I doing something wrong?
Version
4.4.6
Context
Language
Kotlin
Packages
Location
Vertx Verticle
Code
After stuck on the line
transaction.commit().await()
. With a query in PostgreSQL, I can see that the last query from the application to the database isROLLBACK
.PS Everything works fine if I manually make BEGIN/COMMIT requests with SqlConnection instead
sqlConnection.begin()
/transaction.commit()
.