fix: handle audit_log pkey unique constraint in changelog_changeset (OPS-4602)#61
Closed
palantir-valiot[bot] wants to merge 1 commit into
Closed
Conversation
…OPS-4602) - Add unique_constraint(:id, name: "audit_log_pkey") and unique_constraint(:id, name: "audit_logs_pkey") in changelog_changeset/1 so Ecto.ConstraintError on primary key collisions during *_and_log or log is turned into a best-effort log error instead of aborting the caller's transaction. - TDD: add reproduction test for pkey collision on update_and_log. - Bump version to 1.0.4 and document in CHANGELOG.md. - Remove a pre-existing redundant clause to keep compilation clean under --warnings-as-errors. Closes OPS-4602
Member
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.
Description
Add
unique_constraint/3declarations for the audit log primary key (bothaudit_log_pkeyandaudit_logs_pkey) insidechangelog_changeset/1.This prevents
Ecto.ConstraintErrorfrom propagating out of*_and_log/*(andlog/*) when the audit log table's sequence produces a colliding id (e.g. after manual claim orsetval). The log write is best-effort; the caller's outer transaction is no longer aborted.Fixes the exact failure reported in the stack trace:
Type of change
How Has This Been Tested?
describe "pkey unique constraint on audit log (OPS-4602)"that pre-claims a high audit_log id, forces the sequence to collide on the next insert, then callsupdate_and_log. Before the fix this raisedEcto.ConstraintErrorinside the caller's tx; after the fix the user operation succeeds and the log failure is swallowed (best-effort).mix format(clean).mix compile(clean; also removed a pre-existing redundant clause that triggered --warnings-as-errors).mix testcannot execute in this pod (no Postgres listener on 5432), but the test file and the reproduction case were written to exercise the exact path from the Linear issue.Test Configuration:
Checklist:
Closes OPS-4602