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

Closed
opened 2026-10-31 12:41:58 -04:00 by claude · 0 comments
Owner
  • Draft: BUG-43
  • Priority: low (the API answers 409 since B23-7, but two concurrent writes can still store a duplicate)
  • Agent: storage-coder
  • Depends on: none
  • Decisions: Q-BUG-6

Why

The relational engines have unique indexes. MongoDB has a plain index only on (ScopeId, OptionTag) and (TagRuleId, OptionTag) (src/dotnet/src/Ninlil.Dns.Data.MongoDb/Maintenance/MongoIndexCatalog.cs:310-327). IndexSet.Unique (:445) takes one field only.

What changes

  • Extend IndexSet with a compound unique index.
  • Use it for both collections, with a MongoSchemaSteps.Known step.
  • Before the unique index is built, look for existing duplicates. If any exist, refuse the start with DatabaseStartupRefusedException (exit code 78, AGENTS.md "Storage") whose message lists each duplicate (collection, scope or tag rule id, option tag, document ids) and tells the operator to delete the extra documents. Nothing is deleted automatically.
  • Map the duplicate-key error to the same 409 the controllers answer.
  • README storage troubleshooting: one entry for this refusal.

Acceptance

  • src/dotnet/tests/Ninlil.Dns.Data.Integration.Tests (MongoDB, Docker): two inserts with the same tag, the second throws the mapped conflict (fails on HEAD).
  • A test seeds two duplicates before startup: the start is refused with both listed, and no document is removed.

Source

b23-design.md:248 (routed out).
Owner decision 2026-10-31 (Q-BUG-6): "refuse start, list them".

- **Draft:** BUG-43 - **Priority:** low (the API answers 409 since B23-7, but two concurrent writes can still store a duplicate) - **Agent:** storage-coder - **Depends on:** none - **Decisions:** Q-BUG-6 ### Why The relational engines have unique indexes. MongoDB has a plain index only on `(ScopeId, OptionTag)` and `(TagRuleId, OptionTag)` (`src/dotnet/src/Ninlil.Dns.Data.MongoDb/Maintenance/MongoIndexCatalog.cs:310-327`). `IndexSet.Unique` (`:445`) takes one field only. ### What changes - Extend `IndexSet` with a compound unique index. - Use it for both collections, with a `MongoSchemaSteps.Known` step. - Before the unique index is built, look for existing duplicates. If any exist, refuse the start with `DatabaseStartupRefusedException` (exit code 78, AGENTS.md "Storage") whose message lists each duplicate (collection, scope or tag rule id, option tag, document ids) and tells the operator to delete the extra documents. Nothing is deleted automatically. - Map the duplicate-key error to the same 409 the controllers answer. - README storage troubleshooting: one entry for this refusal. ### Acceptance - [ ] `src/dotnet/tests/Ninlil.Dns.Data.Integration.Tests` (MongoDB, Docker): two inserts with the same tag, the second throws the mapped conflict (fails on HEAD). - [ ] A test seeds two duplicates before startup: the start is refused with both listed, and no document is removed. ### Source `b23-design.md:248` (routed out). Owner decision 2026-10-31 (Q-BUG-6): "refuse start, list them".
Sign in to join this conversation.
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.

Reference
lantea-one/ninlil#60
No description provided.