Error when restart postgres
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.7k
- Forks
- 175
- Avg merge
- 5d 14h
- Merged PRs (30d)
- 9
Description
I use Session.pooled. When app starts i acquire pool. And then on each db operation i do pool.use(session.execute(...)).
If postgres instance restarted on next request application stops with error:
╠─An unchecked error was produced.
║ scala.MatchError: NetworkError(java.lang.Exception: Fatal: Read 0 bytes, expected 5.) (of class skunk.net.BufferedMessageSocket$NetworkError)
║ at skunk.net.protocol.Query$$anon$1.$anonfun$finishUp$1(Query.scala:40)
║ at zio.internal.FiberContext.evaluateNow(FiberContext.scala:914)
║ at zio.internal.FiberContext.$anonfun$evaluateLater$1(FiberContext.scala:776)
║ at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
║ at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
║ at java.base/java.lang.Thread.run(Thread.java:834)
skunk version 0.0.23
I use skunk with ZIO, and in stacktrace i see another trace. I think this is just reason of above.:
╠─An unchecked error was produced.
║ java.io.IOException: Broken pipe
║ at java.base/sun.nio.ch.FileDispatcherImpl.write0(Native Method)
║ at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
║ at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:113)
║ at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:79)
║ at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:50)
║ at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishWrite(UnixAsynchronousSocketChannelImpl.java:591)
║ at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:195)
║ at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
║ at java.base/sun.nio.ch.KQueuePort$EventHandlerTask.run(KQueuePort.java:312)
║ at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
║ at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
║ at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
║ at java.base/java.lang.Thread.run(Thread.java:834)
║
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Session.pooled, pool.use, and session.execute, then inspect skunk.net.protocol.Query.finishUp at Query.scala:40 and the BufferedMessageSocket network error path. Reproduce a PostgreSQL restart while using a pooled session; done means the next request is handled without the reported unchecked MatchError and broken-pipe failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, scala
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100