Instances that share one database see each other’s zone and access-rule changes within 60 seconds #276

Merged
claude merged 5 commits from feature/50-cache-ttl-backstop into develop 2026-11-05 02:54:21 -05:00
Owner

Instances that share one database now see each other's zone and access-rule changes within 60 seconds, without a restart (owner decision Q-INT-5). Each cache's TTL is the backstop #71 will keep alongside ValKey.

  • ZoneCacheBackstopService runs every 60 s on the injected TimeProvider. It reads the stored zones and records (from a replica when configured) and compares them with the cached zones by zone fields and by record id and content. Only zones that were added, changed or removed are reloaded, through AuthoritativeZoneCache.ReloadZoneAsync and SignedZoneCache.ReloadZoneAsync, from the primary. An unchanged signed zone is never signed again. CachedZone.StoredRecords keeps the rows #28 leaves out, so a permanently unwritable row is not seen as a change on every pass.
  • DnsAccessControlRuleBackstopService reloads the whole rule set every 60 s from the primary. The table is small, and a replica read on a timer could undo a fresh local change.
  • The backstop reloads caches only. It publishes no DnsZoneChangedEvent, and starts no NOTIFY, PTR sync or webhooks; a test proves it.
  • No schema, API or option change. The README says when another instance's changes appear.

Benchmark (one pass that finds no change, Large: 1,000 zones plus one of 50,000 records; --job short):

Engine Mean Allocated
SQLite 514.0 ms 143.8 MB
PostgreSQL 158.8 ms 89.2 MB

Verified: 7 new tests (5 fail on assertions against a no-op pass; the zone tests passed 5 runs in a row). Authoritative 655, AccessControl 10, Dnssec 122 and Web 2038 tests pass; build 0 warnings.

Known and accepted: a backstop reload and a simultaneous local event reload can briefly store the older read. The next pass heals it, and the same race already exists between two event reloads. Detection loads full record rows; a lighter projection could cut the allocation.

Closes #50

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

Instances that share one database now see each other's zone and access-rule changes within 60 seconds, without a restart (owner decision Q-INT-5). Each cache's TTL is the backstop #71 will keep alongside ValKey. - `ZoneCacheBackstopService` runs every 60 s on the injected `TimeProvider`. It reads the stored zones and records (from a replica when configured) and compares them with the cached zones by zone fields and by record id and content. Only zones that were added, changed or removed are reloaded, through `AuthoritativeZoneCache.ReloadZoneAsync` and `SignedZoneCache.ReloadZoneAsync`, from the primary. An unchanged signed zone is never signed again. `CachedZone.StoredRecords` keeps the rows #28 leaves out, so a permanently unwritable row is not seen as a change on every pass. - `DnsAccessControlRuleBackstopService` reloads the whole rule set every 60 s from the primary. The table is small, and a replica read on a timer could undo a fresh local change. - The backstop reloads caches only. It publishes no `DnsZoneChangedEvent`, and starts no NOTIFY, PTR sync or webhooks; a test proves it. - No schema, API or option change. The README says when another instance's changes appear. Benchmark (one pass that finds no change, Large: 1,000 zones plus one of 50,000 records; `--job short`): | Engine | Mean | Allocated | |---|---|---| | SQLite | 514.0 ms | 143.8 MB | | PostgreSQL | 158.8 ms | 89.2 MB | Verified: 7 new tests (5 fail on assertions against a no-op pass; the zone tests passed 5 runs in a row). Authoritative 655, AccessControl 10, Dnssec 122 and Web 2038 tests pass; build 0 warnings. Known and accepted: a backstop reload and a simultaneous local event reload can briefly store the older read. The next pass heals it, and the same race already exists between two event reloads. Detection loads full record rows; a lighter projection could cut the allocation. Closes #50 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #50

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #50

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The README's cluster-events note points to the one-minute cache check that picks up another instance's change
Some checks failed
Build / Build Binary (macos-amd64) (push) Has been skipped
Build / Smoke Test the Windows Binary (push) Has been skipped
Build / Build and Push Image (push) Has been skipped
Build / Build Arch Linux Packages (push) Has been skipped
Build / Build and Test Deb and RPM Packages (push) Has been skipped
Build / Pipeline (push) Failing after 0s
Build / Publish Release (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Has been skipped
Build / Build Binary (macos-arm64) (pull_request) Has been skipped
Build / Build Binary (linux-amd64) (pull_request) Has been skipped
Build / Build and Test Deb and RPM Packages (pull_request) Has been skipped
Build / Smoke Test the Windows Binary (pull_request) Has been skipped
Build / Publish Release (pull_request) Has been skipped
Build / Build Binary (linux-arm64) (pull_request) Has been skipped
Build / Build Binary (macos-amd64) (pull_request) Has been skipped
Build / Build Binary (windows-amd64) (pull_request) Has been skipped
Build / Build Arch Linux Packages (pull_request) Has been skipped
Build / Build and Push Image (pull_request) Has been skipped
Build / Pipeline (pull_request) Failing after 0s
Build / Test .NET (push) Failing after 7m54s
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-server) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (push) Has been skipped
Build / Build Binary (macos-arm64) (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 (windows-amd64) (push) Has been skipped
06f963c18a
Refs #50

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 30409f3b4b into develop 2026-11-05 02:54:21 -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!276
No description provided.