jfischoff / tmp-postgres

Create temporary postgres instances
BSD 3-Clause "New" or "Revised" License
53 stars 17 forks source link

tmp-postgres fails with uncaught exception: StartError StartPostgresFailed (ExitFailure 1) #278

Open tonyalaribe opened 1 year ago

tonyalaribe commented 1 year ago

Any chance we get more detailed errors?

I've been getting the following crash when I try to run a test with tmp-postgres.

       uncaught exception: StartError
       StartPostgresFailed (ExitFailure 1)

The error doesn't give me any information about what I'm doing wrong, so I have no idea how to proceed other than trying different random things in my hspec withSetup implmentation.

A have a withSetup configured as follows:

withSetup :: (Pool Connection -> IO ()) -> IO ()
withSetup f = do
  -- Helper to throw exceptions
  let throwE x = either throwIO pure =<< x

  throwE $ withDbCache $ \dbCache -> withConfig (cacheConfig dbCache) $ \db -> do
    conn <- liftIO $ connectPostgreSQL (TmpPostgres.toConnectionString db)
    initializationRes <- Migrations.runMigration conn Migrations.defaultOptions MigrationInitialization
    x <- withSnapshot db $ \snapshot -> do
      withConfig (snapshotConfig snapshot) $ \migratedDb -> f =<< createPool (connectPostgreSQL $ toConnectionString migratedDb) close 2 60 10
    pTraceShowM x 
    pass
tonyalaribe commented 1 year ago

Making progress on this, it seems getInitDbVersion panics on this line:

theLastPart = last $ words outputString
versionPart = takeWhile (\x -> isDigit x || x == '.' || x == '-') theLastPart
humanReadable = if last versionPart == '.'
        then init versionPart
        else versionPart

initdb --version is

initdb (PostgreSQL) 14.8 (Homebrew)

on my machine. So the last part is not the version. So last results in a crash.