Skip to content

can't init PostgreSQL migrations: context deadline exceeded #1279

@RouR

Description

@RouR
time=2025-10-02T16:37:21.172Z level=INFO msg="starting Uptrace..." version=v2.0.1 config=/etc/uptrace/config.yml
[bun]  16:37:21.356   BEGIN                   342µs  BEGIN
[bun]  16:37:21.357   SELECT                1.156ms  SELECT pg_advisory_xact_lock(1827954268157431077)
[bun]  16:37:36.344   CREATE TABLE       14.986538s  CREATE TABLE IF NOT EXISTS bun_migrations ("id" BIGSERIAL NOT NULL, "name" VARCHAR, "group_id" BIGINT, "migrated_at" TIMESTAMPTZ NOT NULL DEFAULT current_timestamp, PRIMARY KEY ("id")) 	  context.deadlineExceededError: context deadline exceeded 
[bun]  16:37:36.344   COMMIT                    8µs  COMMIT 	  *errors.errorString: sql: transaction has already been committed or rolled back 
time=2025-10-02T16:37:36.344Z level=WARN msg="failed to release PG lock" err="sql: transaction has already been committed or rolled back"
time=2025-10-02T16:37:36.344Z level=ERROR msg="OnStart hook failed" callee=github.com/uptrace/uptrace/cmd/hosted/serve.initPostgres.func1() caller=github.com/uptrace/uptrace/cmd/hosted/serve.initPostgres error="can't init PostgreSQL migrations: context deadline exceeded"
time=2025-10-02T16:37:36.345Z level=ERROR msg="start failed, rolling back" error="can't init PostgreSQL migrations: context deadline exceeded"
time=2025-10-02T16:37:36.345Z level=ERROR msg="start failed" error="context deadline exceeded"

PostgreSQL 15.4 (Ubuntu 15.4-2.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit

I have run manually this script:

BEGIN;
SELECT pg_advisory_xact_lock(1827954268157431077);
CREATE TABLE IF NOT EXISTS bun_migrations
("id" BIGSERIAL NOT NULL, "name" VARCHAR, "group_id" BIGINT, "migrated_at" TIMESTAMPTZ NOT NULL DEFAULT current_timestamp, PRIMARY KEY ("id"));
CREATE TABLE IF NOT EXISTS tt2 ("id" text null);
ROLLBACK ;
db_uptrace2.public> BEGIN
[2025-10-02 19:40:26] completed in 32 ms
db_uptrace2.public> SELECT pg_advisory_xact_lock(1827954268157431077)
[2025-10-02 19:40:26] 1 row retrieved starting from 1 in 50 ms (execution: 35 ms, fetching: 15 ms)
db_uptrace2.public> CREATE TABLE IF NOT EXISTS bun_migrations
                    ("id" BIGSERIAL NOT NULL, "name" VARCHAR, "group_id" BIGINT, "migrated_at" TIMESTAMPTZ NOT NULL DEFAULT current_timestamp, PRIMARY KEY ("id"))
[2025-10-02 19:40:26] [42P07] relation "bun_migrations" already exists, skipping
[2025-10-02 19:40:26] completed in 35 ms
db_uptrace2.public> CREATE TABLE IF NOT EXISTS tt2 ("id" text null)
[2025-10-02 19:40:26] completed in 51 ms
db_uptrace2.public> ROLLBACK
[2025-10-02 19:40:26] completed in 36 ms

DB seems to be ok.
The error still appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions