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:
- Start the manager against an empty Postgres database with
migrate: true.
POST /api/v1/scheduler-clusters with any valid body.
- Observe
duplicate key value violates unique constraint "scheduler_cluster_pkey" (SQLSTATE 23505).
- 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.
Bug report:
seed()inmanager/database/database.go:142-160inserts the defaultSchedulerClusterwith a hardcodedBaseModel{ID: 1}. On Postgres, explicitly inserting a value does not advance theBIGSERIALsequence, so the first user-drivenPOST /api/v1/scheduler-clusterscollides onid = 1. The retry succeeds atid = 2. Same issue for the seededSeedPeerClusteratdatabase.go:170-180.MySQL, MariaDB, and PolarDB (MySQL-compatible driver) are unaffected:
AUTO_INCREMENTadvances past explicit inserts.Expected behavior:
After a fresh manager startup against Postgres, the first
POST /api/v1/scheduler-clusters(andPOST /api/v1/seed-peer-clusters) should succeed without a primary-key collision.How to reproduce it:
migrate: true.POST /api/v1/scheduler-clusterswith any valid body.duplicate key value violates unique constraint "scheduler_cluster_pkey"(SQLSTATE 23505).id = 2.Environment:
mainat 6dab7f4)