Skip to content
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

FatalError with empty errorMSg, ErrorDetail and ErrorHint #147

Open
R-Aravind opened this issue Aug 26, 2024 · 3 comments
Open

FatalError with empty errorMSg, ErrorDetail and ErrorHint #147

R-Aravind opened this issue Aug 26, 2024 · 3 comments

Comments

@R-Aravind
Copy link

R-Aravind commented Aug 26, 2024

Our application using postgresql-simple 0.6.2 is throwing the below error without any information on queries randomly
It's reproducable but not deterministically, we'll get the following error on any query of our application randomly like one in say 5000 times. The exact same queries would be working every other time, the db host's metrics and connectivity seems to be well under limits and in a healthy condition.

SqlError {sqlState = "", sqlExecStatus = FatalError, sqlErrorMsg = "", sqlErrorDetail = "", sqlErrorHint = ""}

I have traced this issue till the function queryWith_ (Simple.hs:407), it seems to be calling exec to get PQ.Result.
Interestingly, I have found some FIXME comments in the implementation of exec.

...
where
    awaitResult h mres = do
        mfd <- PQ.socket h
        case mfd of
          Nothing -> throwIO $! fdError "Database.PostgreSQL.Simple.Internal.exec"
          Just fd -> do
             threadWaitRead fd
             _ <- PQ.consumeInput h  -- FIXME?
             getResult h mres

    getResult h mres = do
        isBusy <- PQ.isBusy h
        if isBusy
        then awaitResult h mres
        else do
          mres' <- PQ.getResult h
          case mres' of
            Nothing -> case mres of
                         Nothing  -> throwLibPQError h "PQgetResult returned no results"
                         Just res -> return res
            Just res -> do
                status <- PQ.resultStatus res
                case status of
                   -- FIXME: handle PQ.CopyBoth and PQ.SingleTuple
                   PQ.EmptyQuery    -> getResult h mres'
                   ...

Any ideas or pointers to fix this issue would be very helpful, also is this a know issue?

@haskellari haskellari deleted a comment Aug 26, 2024
@phadej
Copy link
Collaborator

phadej commented Aug 26, 2024

0.6.2 is an old release. While I don't think the issue is fixed, having a reproducer with the latest release of postgresql-simpl (and postgresql-libpq) is the most important first step. I won't look into older releases.

@R-Aravind
Copy link
Author

R-Aravind commented Aug 26, 2024

Sure, I will try to reproduce it with the latest releases.
@phadej Any ideas on what could be the probable causes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@phadej @R-Aravind and others