-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: queries with ON CONFLICT DO UPDATE SET seem to interfere each other when run in parallel #82392
Comments
NB: The error seems to be more related to two connections trying to commit at the same time. I tried turning off the auto commit and manually added |
I played with this example a little bit more. The issue also only happens if the two threads are trying to write the same values. (I changed it so one of the threads had an initial |
I added additional logging to e852be5ca4 (the working commit).
Note that session ID A theory I have is that after 9fdb39b, CRDB is still trying to retry the statement, but it also retries the |
#82622 fixes this, but I need to figure out how to write a unit test for it. |
Describe the problem
We spinned up 2 threads to run the same
INSERT INTO ... ON CONFLICT DO UPDATE SET ...
query in parallel. To do that we started a connection pool withmaximum pool size == 2 connections
. When running against the latest built from master we encountered the following error:This seems to be a regression caused by commit 9fdb39b49e. It passed with a built prior to this commit.
To Reproduce
We used HikariCP 5.0.0 as the connection pool, and run the query with the following
insertSameValInParallel.java
.We spinned up a cockroach server with
./cockroach start-single-node --insecure --store=cockroach-data --advertise-addr=localhost
.We tested against the binary built at the
a) current latest commit in master (2181204e9c)
b) 9fdb39b49e
c) e852be5ca4 (the newest commit prior to #9fdb39b49e)
a) and b) failed with the
org.postgresql.util.PSQLException: ERROR: there is already a transaction in progress
error and c) passedNote that any of following changes in
insertSameValInParallel.java
will make it pass:conn.setAutoCommit(false);
ininsertVal()
.ON CONFLICT DO NOTHING
.Expected behavior
The queries should not fail.
Additional data / screenshots
The whole error message is
Environment:
./cockroach start-single-node --insecure
Additional context
This issue is originally from a support ticket.
Jira issue: CRDB-16346
gz#12585
The text was updated successfully, but these errors were encountered: