hasura / pg-client-hs

A low level Haskell library to connect to postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

possible resource leak, connection not always actively destroyed

robx opened this issue · comments

We create libpq connections with initPQConn:

conn <- PQ.connectdb (pgConnString $ ciDetails ci)

  1. Then if we're not happy with the connection (or something goes wrong figuring that out), we throw it away, leaving the call to PQfinish to the foreign pointer finalizer.

  2. In the pool initializer:

    pqConn <- initPQConn ci logger
    , the connection created by initPQConn will again not be finalized if something goes wrong later in the creator (e.g. exception thrown by EKG.Distribution.Add).