MongoDB refuses a second DHCP custom option with the same tag on a scope or tag rule, and refuses to start on existing duplicates #312

Merged
claude merged 3 commits from feature/60-mongo-dhcp-option-unique into develop 2026-11-05 13:39:26 -05:00
Owner

MongoDB now refuses a second DHCP custom option with the same tag on one scope or tag rule, and refuses to start when duplicates already exist (owner decision Q-BUG-6: refuse start, list them).

  • IndexSet.Unique takes several fields; NinlilDhcpScopeCustomOptions (ScopeId, OptionTag) and NinlilDhcpTagRuleOptions (TagRuleId, OptionTag) get unique indexes through a new step, MongoSchemaSteps.DhcpCustomOptionUniqueIndexes (appended last in Known).
  • The step scans both collections first. Any duplicate refuses the start with DatabaseStartupRefusedException (exit 78) listing collection, owner, tag and document ids; nothing is deleted and the step is not recorded, so a cleaned database starts next time. A duplicate written between the scan and the build is caught (11000 on create) and listed the same way.
  • On an existing database the plain index is dropped by name and the unique one created. Concurrent first starts on several nodes are safe: IndexNotFound on the drop counts as success, and a concurrent create of the same spec is accepted once the unique index exists.
  • MongoChangeTracker maps a duplicate-key error (11000) to ConflictException, which the controllers answer as 409, and logs the driver error (collection and index) at Warning. Nothing in the code catches the driver exceptions, so the mapping changes no handled path (verifier checked every caller; the other unique index is SecondaryZoneRefreshStates.ZoneId).
  • README "When the start is refused (exit code 78)" table: one row.
  • The relational engines still answer a concurrent duplicate with 500; filed as #311.

Tests (MongoDhcpCustomOptionUniquenessTests, MongoDB container): duplicate scope option and tag-rule option throw the conflict; seeded duplicates refuse the start with both listed and nothing deleted; the plain index becomes exactly one unique index; 6 concurrent runs over plain indexes succeed; a duplicate arriving after the scan is listed. The first four fail on develop. Integration Mongo 140, Data.Tests 124, Web.Tests 2081 (without Docker); build 0 warnings; csharpier clean.

Closes #60

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

MongoDB now refuses a second DHCP custom option with the same tag on one scope or tag rule, and refuses to start when duplicates already exist (owner decision Q-BUG-6: refuse start, list them). - `IndexSet.Unique` takes several fields; `NinlilDhcpScopeCustomOptions` (ScopeId, OptionTag) and `NinlilDhcpTagRuleOptions` (TagRuleId, OptionTag) get unique indexes through a new step, `MongoSchemaSteps.DhcpCustomOptionUniqueIndexes` (appended last in `Known`). - The step scans both collections first. Any duplicate refuses the start with `DatabaseStartupRefusedException` (exit 78) listing collection, owner, tag and document ids; nothing is deleted and the step is not recorded, so a cleaned database starts next time. A duplicate written between the scan and the build is caught (11000 on create) and listed the same way. - On an existing database the plain index is dropped by name and the unique one created. Concurrent first starts on several nodes are safe: IndexNotFound on the drop counts as success, and a concurrent create of the same spec is accepted once the unique index exists. - `MongoChangeTracker` maps a duplicate-key error (11000) to `ConflictException`, which the controllers answer as 409, and logs the driver error (collection and index) at Warning. Nothing in the code catches the driver exceptions, so the mapping changes no handled path (verifier checked every caller; the other unique index is `SecondaryZoneRefreshStates.ZoneId`). - README "When the start is refused (exit code 78)" table: one row. - The relational engines still answer a concurrent duplicate with 500; filed as #311. Tests (`MongoDhcpCustomOptionUniquenessTests`, MongoDB container): duplicate scope option and tag-rule option throw the conflict; seeded duplicates refuse the start with both listed and nothing deleted; the plain index becomes exactly one unique index; 6 concurrent runs over plain indexes succeed; a duplicate arriving after the scan is listed. The first four fail on develop. Integration Mongo 140, Data.Tests 124, Web.Tests 2081 (without Docker); build 0 warnings; csharpier clean. Closes #60 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #60

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #60

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The MongoDB DHCP option index step keeps its test hook internal to the library
Some checks failed
Build / Test .NET (push) Failing after 8m35s
Build / Stage Draft Release (push) Has been skipped
Build / Pack and Push NuGet Packages (common) (push) Has been skipped
Build / Pack and Push NuGet Packages (dhcp) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-server) (push) Has been skipped
Build / Build Binary (linux-amd64) (push) Has been skipped
Build / Build Binary (linux-arm64) (push) Has been skipped
Build / Build Binary (macos-amd64) (push) Has been skipped
Build / Build Binary (macos-arm64) (push) Has been skipped
Build / Build Binary (windows-amd64) (push) Has been skipped
Build / Build Arch Linux Packages (push) Has been skipped
Build / Smoke Test the Windows Binary (push) Has been skipped
Build / Build and Test Deb and RPM Packages (push) Has been skipped
Build / Build and Push Image (push) Has been skipped
Build / Publish Release (push) Has been skipped
Build / Pipeline (push) Failing after 0s
Build / Build Binary (macos-arm64) (pull_request) Successful in 0s
Build / Build Binary (windows-amd64) (pull_request) Successful in -9s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in 3m14s
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in 4m4s
Build / Build Binary (linux-arm64) (pull_request) Successful in 5m15s
Build / Build Binary (linux-amd64) (pull_request) Successful in 5m17s
Build / Build Binary (macos-amd64) (pull_request) Successful in 5m19s
Build / Build and Push Image (pull_request) Successful in 10s
Build / Smoke Test the Windows Binary (pull_request) Successful in 16s
Build / Build Arch Linux Packages (pull_request) Successful in 57s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in 2m15s
Build / Publish Release (pull_request) Successful in 4s
Build / Pipeline (pull_request) Successful in 0s
432baa3100
Refs #60

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 8ca91a7e85 into develop 2026-11-05 13:39:26 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!312
No description provided.