allaboutapps / integresql

IntegreSQL manages isolated PostgreSQL databases for your integration tests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New version change of behaviour, Integresql is not waiting for DB to finish creating

bartoszhernas opened this issue · comments

Hi, after we upgraded to newest IntegreSQL we noticed tests started failing randomly with error that the DB we try to use doesn't exist.

I pinpointed the issue to query creating DB in PostgreSQL and not waiting for it to finish, while the client libraries would continue executing and trying to not (yet) existing DB.

postgres-1  | 2024-02-09 12:18:27.531 UTC [3827] LOG:  statement: CREATE DATABASE "integresql_test_00bd369da024925dba2efdb4ce82cffc421b349d_020" WITH OWNER "fym" TEMPLATE "integresql_template_00bd369da024925dba2efdb4ce82cffc421b349d"
postgres-1  | 2024-02-09 12:18:27.531 UTC [3833] FATAL:  database "integresql_test_00bd369da024925dba2efdb4ce82cffc421b349d_020" does not exist
postgres-1  | 2024-02-09 12:18:27.531 UTC [3833] DETAIL:  It seems to have just been dropped or renamed.

It was working just fine with previous version, so I am guessing there was some change in IntegreSQL?

The fix for us right now was to try to connect to DB multiple times until it works

  let retriesConnectMain = 0;
  while (retriesConnectMain < 10) {
    try {
      // eslint-disable-next-line no-await-in-loop
      await prismaMain.$connect();
      break;
    } catch (e) {
      retriesConnectMain += 1;
      // eslint-disable-next-line no-await-in-loop
      await wait(100);
    }
  }

Experienced the same thing in CI builds on Azure DevOps after upgrading (tests were running fine on v1.0, but are not finding the DB in v1.1).
Running tests locally worked for me, though

is this library still maintained? I'm running into a variation of this bug.