A concurrent duplicate write on a relational engine answers 409, not 500 #311
Labels
No labels
agent
api-regen
agent
architect
agent
coder
agent
console-coder
agent
docs-writer
agent
mechanic
agent
protocol-coder
agent
storage-coder
area/api
area/ci
area/console
area/dhcp
area/dns
area/docs
area/packaging
area/process
area/storage
area/windows
kind
bug
kind
chore
kind
docs
kind
epic
kind
feature
kind
performance
kind
security
kind
test
priority
high
priority
low
priority
medium
resolution
duplicate
resolution
not-a-bug
resolution
wontfix
status
blocked
status
in-progress
status
needs-decision
status
needs-design
status
ready
theme
ad-samba-dns
theme
alternatives-benchmark
theme
console-toolchain
theme
later
theme
parity-devices
theme
parity-query
theme
post-release-fixes
theme
tracker-setup
theme
valkey
theme
windows-installer
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
lantea-one/ninlil#311
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
On SQLite, PostgreSQL, MySQL and SQL Server a write that breaks a unique index surfaces as a 500. The controllers check for a duplicate first and answer 409 with
ConflictException, but two concurrent writes both pass the check, and the second fails insideSaveChangeswith aDbUpdateException. Nothing insrcmaps it (NinlilExceptionHandlermaps only the Ninlil exception types). Examples: the unique indexes on DHCP custom options insrc/dotnet/src/Ninlil.Dns.Data.EntityFrameworkCore/Configuration/DhcpScopeCustomOptionConfiguration.cs:39-40andDhcpTagRuleOptionConfiguration.cs:36-37; the controller comments inDhcpScopeCustomOptionsController.cs:204-209andDhcpTagRuleOptionsController.cs:197-202describe the 500.#60 maps MongoDB's duplicate-key error (11000) to
ConflictExceptioninMongoChangeTracker.FlushAsync, so MongoDB answers 409 for the same race.What changes
Ninlil.Dns.Data.EntityFrameworkCore), map aDbUpdateExceptioncaused by a unique-constraint violation toConflictException, for each provider (SQLiteSQLITE_CONSTRAINT_UNIQUE2067 / primary key 1555, PostgreSQL SQLSTATE 23505, MySQL 1062, SQL Server 2601 and 2627). Log the original error before rethrowing. Leave otherDbUpdateExceptions as they are.Acceptance
src/dotnet/tests/Ninlil.Dns.Data.Integration.Tests: on every relational engine, a second insert of the same DHCP option tag on one scope that bypasses the controller's pre-check throwsConflictException(fails on HEAD). SQLite without Docker; the others with theRequiresDockertrait.DbUpdateException(for example a foreign-key violation) is not turned into a conflict.Source
Verifier report on #60 (
feature/60-mongo-dhcp-option-unique).Ghost referenced this issue2026-11-05 13:38:17 -05:00
Ghost referenced this issue2026-11-05 15:58:55 -05:00