Skip to content

Default seeded scheduler cluster uses ID 1 without incrementing the SERIAL on Postgres #4752

Description

@ouillie

Bug report:

seed() in manager/database/database.go:142-160 inserts the default SchedulerCluster with a hardcoded BaseModel{ID: 1}. On Postgres, explicitly inserting a value does not advance the BIGSERIAL sequence, so the first user-driven POST /api/v1/scheduler-clusters collides on id = 1. The retry succeeds at id = 2. Same issue for the seeded SeedPeerCluster at database.go:170-180.

MySQL, MariaDB, and PolarDB (MySQL-compatible driver) are unaffected: AUTO_INCREMENT advances past explicit inserts.

Expected behavior:

After a fresh manager startup against Postgres, the first POST /api/v1/scheduler-clusters (and POST /api/v1/seed-peer-clusters) should succeed without a primary-key collision.

How to reproduce it:

  1. Start the manager against an empty Postgres database with migrate: true.
  2. POST /api/v1/scheduler-clusters with any valid body.
  3. Observe duplicate key value violates unique constraint "scheduler_cluster_pkey" (SQLSTATE 23505).
  4. Retry the same request: it now succeeds with id = 2.

Environment:

  • Dragonfly version: v2.4.0 (also main at 6dab7f4)
  • OS: any
  • Kernel: n/a
  • Others: Postgres only.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions