Comments (6)
I managed to reproduce the bug. Postgres reports the error as
postgres_1 | 2020-04-21 18:40:55.456 UTC [27] ERROR: insert or update on table "foo" violates foreign key constraint "foo_bar_id_fkey"
https://github.com/megri/skunk-bugreport
from skunk.
I rewrote my bug report with natchez-log but traces are never logged as the process deadlocks before it comes that far. I also noticed that deadlock seemingly occurs for any INSERT queries with RETURNING, that fails for at least foreign key violation error.
Adding readTimeout/writeTimeout arguments to the session pool does not prevent deadlock.
from skunk.
Log from start to the point of deadlock
→ StartupMessage(postgres,postgres)
← AuthenticationOk
← ParameterStatus(application_name,)
← ParameterStatus(client_encoding,UTF8)
← ParameterStatus(DateStyle,ISO, MDY)
← ParameterStatus(integer_datetimes,on)
← ParameterStatus(IntervalStyle,iso_8601)
← ParameterStatus(is_superuser,on)
← ParameterStatus(server_encoding,UTF8)
← ParameterStatus(server_version,11.7)
← ParameterStatus(session_authorization,postgres)
← ParameterStatus(standard_conforming_strings,on)
← ParameterStatus(TimeZone,UTC)
← BackendKeyData(161,1923859743)
← ReadyForQuery(Idle)
→ Parse(statement_1,INSERT INTO "foo" ("bar_id") VALUES ($1) RETURNING *,List(20))
→ Flush
← ParseComplete
→ Describe(S, statement_1)
→ Flush
← ParameterDescription(List(20))
← RowDescription(Field(id, 20); Field(bar_id, 20))
→ Bind(portal_2,statement_1,List(Some(42)))
→ Flush
← BindComplete
→ Execute(portal_2,2)
→ Flush
← ErrorResponse(s -> public, n -> foo_bar_id_fkey, t -> foo, F -> ri_triggers.c, M -> insert or update on table "foo" violates foreign key constraint "foo_bar_id_fkey", V -> ERROR, L -> 2772, C -> 23503, R -> ri_ReportViolation, D -> Key (bar_id)=(42) is not present in table "bar"., S -> ERROR
→ Close(P,portal_2)
→ Flush
from skunk.
It seems plausible that the code deadlocks @ https://github.com/tpolecat/skunk/blob/29741a10acba5f4dff51b5c66d007065b313ad11/modules/core/src/main/scala/net/protocol/Close.scala#L40, expecting a CloseComplete
that never comes.
from skunk.
From https://www.postgresql.org/docs/11/protocol-flow.html (emphasis mine):
The Close message closes an existing prepared statement or portal and releases resources. It is not an error to issue Close against a nonexistent statement or portal name. The response is normally CloseComplete, but could be ErrorResponse if some difficulty is encountered while releasing resources. Note that closing a prepared statement implicitly closes any open portals that were constructed from that statement.
Could this be the cause?
from skunk.
As it seems the fix resolved the issue for me I'll close it now!
from skunk.
Related Issues (20)
- Type inference for type argument in `to[A]` no longer working HOT 1
- Deadlock while using session pool HOT 1
- Unhandled backend message HOT 1
- NumberFormatException when parsing OID values exceeding 32-bit signed integer range HOT 7
- e HOT 1
- Feature request: logical replication HOT 2
- Support dynamic passwords HOT 1
- Should AppliedFragment Monoid use spaces?
- postgis types are a bit too generic
- Skunk sends all arguments to tracing/logging HOT 6
- Fragment's stripMargin can change the query
- Exceptions in transactions are printed to stderr HOT 3
- Skunk can't find `enum` type in schema HOT 3
- Support query pipelineing in a single session HOT 1
- Relax reliance on `SocketGroup` HOT 1
- Feature reqest: migrations. HOT 1
- Extending the sql interpolator?
- Session pool examples [Question]
- decode joined rows
- Fragment interpolation breaks with nested fragments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skunk.