Skip to content

Commit d865c91

Browse files
committed
db: set idle_in_transaction_session_timeout to 30s
A Skunk session that crashes mid-transaction could otherwise hold Postgres locks indefinitely until the pool recycles the connection. 30 s is generous enough for normal bulk-upsert operations while still providing a safety net.
1 parent 1bf17d3 commit d865c91

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

modules/db/src/main/scala/DbResource.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ object DbResource:
3333
.withDatabase(c.database)
3434
.withSSL(if c.ssl then SSL.Trusted else SSL.None)
3535
.withTypingStrategy(TypingStrategy.SearchPath)
36-
.withConnectionParameters(Map("search_path" -> c.schema) ++ Session.DefaultConnectionParameters)
36+
.withConnectionParameters(
37+
Map(
38+
"search_path" -> c.schema,
39+
// Kill sessions that are idle inside a transaction after 30 s.
40+
// Prevents stalled Skunk sessions from holding locks indefinitely.
41+
"idle_in_transaction_session_timeout" -> "30000"
42+
) ++ Session.DefaultConnectionParameters
43+
)
3744
.pooled(c.max)
3845
.evalTap(checkPostgresConnection)
3946

0 commit comments

Comments
 (0)