fix(database): reset scheduler_cluster postgres sequence after seeding default cluster#4857
Open
anxkhn wants to merge 1 commit into
Open
fix(database): reset scheduler_cluster postgres sequence after seeding default cluster#4857anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
…g default cluster The postgres sequence reset after seeding the default scheduler cluster passed "seed_peer_cluster" as the table name instead of "scheduler_cluster", so setval targeted the wrong sequence. As a result the scheduler_cluster serial sequence was never advanced past the explicitly inserted id=1, and the seed_peer_cluster sequence was reset twice. On a fresh Postgres manager this leaves the scheduler_cluster sequence at 1 after seeding, so creating a second scheduler cluster draws id=1 again and fails with a duplicate key violation (SQLSTATE 23505), the exact regression that dragonflyoss#4752 reported. Point the reset at "scheduler_cluster" so its sequence is advanced after the explicit-ID seed insert. The seed peer cluster block already resets "seed_peer_cluster" correctly. Refs dragonflyoss#4752 Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4857 +/- ##
=======================================
Coverage 28.12% 28.12%
=======================================
Files 232 232
Lines 23157 23157
=======================================
Hits 6512 6512
Misses 16197 16197
Partials 448 448
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
This completes the fix for the regression originally reported in #4752. The fix
that was merged for that issue advanced the wrong sequence for the scheduler
cluster, so the scheduler-cluster case described in #4752 still reproduces.
(#4752 is closed; I can open a fresh tracking issue if the maintainers prefer a
new open issue linked to this PR.)
Motivation and Context
On a fresh Postgres manager (
migrate: true), seeding insertsscheduler_clusterwithid = 1but leaves that table's serial sequence at1.The next insert into
scheduler_cluster(for example the firstPOST /api/v1/scheduler-clusters) drawsid = 1again and fails withduplicate key value violates unique constraint "scheduler_cluster_pkey"(
SQLSTATE 23505), exactly the symptom from #4752.setPostgresSequenceis ano-op on non-Postgres drivers, and MySQL/MariaDB/PolarDB advance
AUTO_INCREMENTpast explicit inserts, so only Postgres is affected.Screenshots (if appropriate)
N/A
Types of changes
Checklist