fergusstrange / embedded-postgres

Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test
MIT License
851 stars 89 forks source link

Get error "unable to extract postgres archive: xz: data is truncated or corrupt" in GitLab pipeline. #97

Closed nahojer closed 1 year ago

nahojer commented 1 year ago

When starting the postgres daemon, I get the following error:

unable to extract postgres archive: xz: data is truncated or corrupt

This never happens locally, but only in a GitLab pipeline. Furthermore, it only seems to happen on parallel runs of the postgres daemon -- I start one postgres daemon on a different port for each test function.

We start the postgres daemon in the following way

runtimePath := filepath.Join(projectDir, ".dbtest", t.Name())
pg := embeddedpostgres.NewDatabase(embeddedpostgres.DefaultConfig().
    Username(user).
    Password(pw).
    Database(dbname).
    Version(embeddedpostgres.V14).
    RuntimePath(runtimePath).
    DataPath(fmt.Sprintf("%s/data", runtimePath)).
    Logger(os.Stdout).
    Port(port).
    StartTimeout(45 * time.Second))

if err := pg.Start(); err != nil {
    t.Fatalf("Failed to start embedded postgres daemon: %s\n", err)
}

I have also experimented with the BinariesPath option, but without any luck.

Any ideas of what the real issue is and how one might go about resolving it?

nahojer commented 1 year ago

Just realized this might be a duplicate of https://github.com/fergusstrange/embedded-postgres/issues/96. Sorry for that.

fergusstrange commented 1 year ago

Yes this does look to be the same. I'll try to tackle this soon.