-
Notifications
You must be signed in to change notification settings - Fork 847
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
defer largeObject.close seem to cause a race condition (break connection in a weird way - causes 'conn busy') #1908
Comments
maybe related to: #710 |
Because the close large object call is deferred your transaction is committed before the large object is closed. That can't be done. |
Hi @jackc, thank you for the quick reply. |
I tracked the problem down to a missing check if the transaction was already closed inside of What you are doing should work now, but it's still a little sketchy to call Though if it is automatically closed when the transaction is closed, maybe the |
@jackc thank you for fixing it! |
Describe the bug
After using "defer obj.close" in a function, other functions that get the released connection from the pool fail with 'conn busy'
There seems to be a race condition.
To Reproduce
A runnable example: (this is the smallest one I managed to create, note if "defer obj.close" is removed, everything works fine.
Please run your example with the race detector enabled. For example,
go run -race main.go
orgo test -race
.Expected behavior
Actual behavior
Version
Go:
$ go version
-> go1.21.6 darwin/arm64PostgreSQL:
$ psql --no-psqlrc --tuples-only -c 'select version()'
-> PostgreSQL 16.0 on aarch64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.102), 64-bitpgx:
$ grep 'github.com/jackc/pgx/v[0-9]' go.mod
-> v4.18.1The text was updated successfully, but these errors were encountered: