yesodweb / yesodweb/persistent

Catching errors when connecting to database

Open
#1,354 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

When the database is under maintenance or similar, runSqlPool and similar unsurprisingly throw an exception.

We want to catch that exception during the connecting stage, so we can wait briefly and then try again.

However catching the entire runSqlPool call will also catch any errors that occur after a successful connection, which I do not want to lead to a retry.

I'm curious if I am missing something and there already is a safe and easy way to do such a thing, but if not it'd be very useful if it were supported.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the runSqlPool entry point and similar database operations to identify which part represents the connecting stage. Clarify the proposed retry boundary and behavior for connection failures versus errors after a successful connection. Done means the supported behavior and its scope are documented and covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.