timescale / timescaledb-docker-ha

Create Docker images containing TimescaleDB, Patroni to be used by developers and Kubernetes.
Apache License 2.0
143 stars 38 forks source link

Error in GitHub actions when running the `timescaledb-ha:pg16` docker image in `testcontainers-go` #476

Open morris-kelly opened 2 days ago

morris-kelly commented 2 days ago

In the last few hours, I've started getting failing tests in GitHub actions with the following logs:

CREATE DATABASE
/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/000_install_timescaledb.sh
CREATE EXTENSION
CREATE EXTENSION
2024-07-02 14:40:46.537 UTC [58] ERROR:  TimescaleDB background worker connected to template database, exiting
2024-07-02 14:40:46.543 UTC [34] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 58) exited with exit code 1
CREATE EXTENSION
/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/001_timescaledb_tune.sh
/docker-entrypoint-initdb.d/001_timescaledb_tune.sh: line 42: [: max: integer expression expected
Using postgresql.conf at this path:
/home/postgres/pgdata/data/postgresql.conf
Writing backup to:
/tmp/timescaledb_tune.backup202407021440
panic: bytes must be at least 1 byte (got 0)
goroutine 1 [running]:
github.com/timescale/timescaledb-tune/internal/parse.parseIntToFloatUnits(0xc0000b5c50?)
    /home/builder/go/pkg/mod/github.com/timescale/timescaledb-tune@v0.15.0/internal/parse/parse.go:115 +0x159
github.com/timescale/timescaledb-tune/internal/parse.BytesToDecimalFormat(0x0?)
    /home/builder/go/pkg/mod/github.com/timescale/timescaledb-tune@v0.15.0/internal/parse/parse.go:138 +0x1d
github.com/timescale/timescaledb-tune/pkg/tstune.(*Tuner).processQuiet(0xc0000b5f18, 0xc0000a1200, 0xc000282de0?)
    /home/builder/go/pkg/mod/github.com/timescale/timescaledb-tune@v0.15.0/pkg/tstune/tuner.go:[65](https://github.com/synaptecltd/synthesis/actions/runs/9763033277/job/26947904939#step:8:66)9 +0x66
github.com/timescale/timescaledb-tune/pkg/tstune.(*Tuner).Run(0xc0000b5f18, 0xc00005a000?, {0x530a28, 0xc00009a000}, {0x530a48, 0xc00009a008}, {0x530a48, 0xc00009a010})
    /home/builder/go/pkg/mod/github.com/timescale/timescaledb-tune@v0.15.0/pkg/tstune/tuner.go:300 +0x52c
main.main()
    /home/builder/go/pkg/mod/github.com/timescale/timescaledb-tune@v0.15.0/cmd/timescaledb-tune/main.go:65 +0x117

This can be reproduced by running this test in a CI pipeline

package main

import (
    "context"
    "testing"

    "github.com/testcontainers/testcontainers-go"
    "github.com/testcontainers/testcontainers-go/modules/postgres"
    "github.com/testcontainers/testcontainers-go/wait"
)

func TestTimescaleIntegration(t *testing.T) {
    dbUser := "postgres"
    dbPassword := "postgres"
    dbName := "postgres"

    _, err := postgres.RunContainer(context.TODO(),
        testcontainers.WithImage("timescale/timescaledb-ha:pg16"),
        postgres.WithDatabase(dbName),
        postgres.WithUsername(dbUser),
        postgres.WithPassword(dbPassword),
        testcontainers.WithWaitStrategy(
            wait.ForLog("database system is ready to accept connections").WithOccurrence(2)),
    )
    if err != nil {
        t.Fatal(err)
    }
}

I have had the exact same error with timescale/timescaledb-ha:pg15 and timescale/timescaledb-ha:pg16.3-ts2.15.2

Changing the image to testcontainers.WithImage("timescale/timescaledb:latest-pg16") enables the test to pass, which suggests that this is an issue with the -ha image.

Running with timescale/timescaledb-ha:pg16.3-ts2.15.1 pinned passes the tests also.

Running the failing images locally also works, this issue is only in GitHub actions.

devanubis commented 2 days ago

We've also had this exact same issue today with our CI pipeline, which is using timescale/timescaledb-ha:pg14-all.

For now we've pinned to pg14.12-ts2.15.1-all.

us77ipis commented 1 day ago

Same issue here with timescale/timescaledb-ha:pg16.

holasoftware commented 1 day ago

It's working for me using the environment variable -e NO_TS_TUNE=true

docker run -d --name timescaledb -p 5433:5432 -e NO_TS_TUNE=true -e POSTGRES_PASSWORD=postgres timescale/timescaledb-ha:pg16

The issue is related to this script only docker-entrypoint-initdb.d/001_timescaledb_tune.sh

us77ipis commented 11 hours ago

For me it is working now again with timescale/timescaledb-ha:pg16 too.