Skip to content

FatalError with empty errorMSg, ErrorDetail and ErrorHint #147

Open
@R-Aravind

Description

@R-Aravind

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions