Zone and access-rule cache TTL backstop: instances that share one database see each other's zone and access-rule changes within 60 seconds #50

Closed
opened 2026-10-31 12:41:57 -04:00 by claude · 0 comments
Owner
  • Draft: REL-45
  • Priority: medium (an edit on instance A stays invisible on instance B until a restart)
  • Agent: coder
  • Depends on: none
  • Decisions: Q-INT-5

Why

Every other DNS cache reloads by age (60 s for the client directory, filter configuration,
rewrites, schedules and forwarder zones; README.md:5092-5098). The zone, signed-zone and
access-rule caches reload only at startup and on a local event:

  • AuthoritativeZoneCache (src/dotnet/src/Ninlil.Dns.Server.Authoritative/Cache/AuthoritativeZoneCache.cs:31-68,142-181),
    reloaded by ZoneChangedEventSubscriber (Cache/ZoneChangedEventSubscriber.cs:12-19).
  • SignedZoneCache (Dnssec/SignedZoneCache.cs:69-73,150).
  • DnsAccessControlRuleCache (src/dotnet/src/Ninlil.Dns.Server.AccessControl/DnsAccessControlRuleCache.cs:39-40,75-99).
    An instance ignores events made by another instance (README.md:4199-4204). So two instances on
    one database never see each other's zone or access-rule changes. #71 adds instant cross-node
    expiry through ValKey and keeps each cache's TTL as its backstop; this issue gives these three
    caches that backstop.

What changes

  • Access rules: a timer reloads the whole rule set every 60 s (ReloadAsync; the table is small
    and flat, as the class summary says).
  • Zones: a new hosted service in Ninlil.Dns.Server.Authoritative/Cache/ runs every 60 s and
    only detects changes:
    1. It reads the enabled zones and the records of the answerable ones with the two queries
      AuthoritativeZoneCache.StartAsync already runs (:45-60).
    2. It compares each zone with the cached CachedZone: the zone row fields the caches use, and
      the record set by id and content. AuthoritativeZoneCache gets a read-only accessor for
      this.
    3. For each zone added, changed or removed it calls AuthoritativeZoneCache.ReloadZoneAsync
      and SignedZoneCache.ReloadZoneAsync, the pair the event subscribers use.
      Detection data is never written into a cache. A reload reads fresh from the primary, so a
      local change made between the detection read and the reload is never undone. An unchanged
      zone is not touched, so a signed zone is re-signed only when it changed.
  • Detection reads may use CreateReplicaReadScope (the age-reload rule in AGENTS.md "Read
    replicas"); the reload methods keep reading the primary. Update the comments at
    AuthoritativeZoneCache.cs:33-35,144-146, SignedZoneCache.cs:71-73 and
    DnsAccessControlRuleCache.cs:77-79, which say "never on a timer".
  • The backstop reloads caches only. It must not publish DnsZoneChangedEvent or start NOTIFY,
    PTR sync or webhooks; README.md:4199-4204 stays true.
  • Interval: a constant 60 s, like the other caches. Use the injected TimeProvider so tests can
    drive it. No new option.
  • A benchmark under src/dotnet/benchmarks/Ninlil.Benchmarks/Dns/ measures one detection pass
    at Large (1,000 zones plus one of 50,000 records) on SQLite and PostgreSQL. Copy the numbers
    into the PR.
  • README.md:5092-5098 and 4185-4190: zone and access-rule changes made on another instance that
    shares the database show up after at most 60 seconds, plus the replica lag limit. #76 later
    adds the ValKey bound to the same text.

Acceptance

  • Authoritative.Tests, red first: two AuthoritativeZoneCache and SignedZoneCache pairs on
    one SQLite file; a record written straight through the repository (as another instance
    would) is answered by the second cache after the fake time advances 61 s. An unchanged
    signed zone is not signed again (count signing calls). A deleted zone disappears.
  • AccessControl.Tests, red first: a rule added through the repository is in effect after 61 s
    of fake time.
  • A test proves the backstop publishes no DnsZoneChangedEvent.
  • dotnet test src/dotnet/tests/Ninlil.Dns.Server.Authoritative.Tests,
    src/dotnet/tests/Ninlil.Dns.Server.AccessControl.Tests and
    src/dotnet/tests/Ninlil.Web.Tests (DI wiring) pass.
  • No schema, API or option change.

Source

INT.md #71 and Q-INT-5; README.md:4185-4204, 5086-5098; DEDUPE.md §2.
Owner decision 2026-10-31 (Q-INT-5): "60 s TTL backstop now, as a post-release-fixes issue".

- **Draft:** REL-45 - **Priority:** medium (an edit on instance A stays invisible on instance B until a restart) - **Agent:** coder - **Depends on:** none - **Decisions:** Q-INT-5 ### Why Every other DNS cache reloads by age (60 s for the client directory, filter configuration, rewrites, schedules and forwarder zones; README.md:5092-5098). The zone, signed-zone and access-rule caches reload only at startup and on a local event: - `AuthoritativeZoneCache` (`src/dotnet/src/Ninlil.Dns.Server.Authoritative/Cache/AuthoritativeZoneCache.cs:31-68,142-181`), reloaded by `ZoneChangedEventSubscriber` (`Cache/ZoneChangedEventSubscriber.cs:12-19`). - `SignedZoneCache` (`Dnssec/SignedZoneCache.cs:69-73,150`). - `DnsAccessControlRuleCache` (`src/dotnet/src/Ninlil.Dns.Server.AccessControl/DnsAccessControlRuleCache.cs:39-40,75-99`). An instance ignores events made by another instance (README.md:4199-4204). So two instances on one database never see each other's zone or access-rule changes. #71 adds instant cross-node expiry through ValKey and keeps each cache's TTL as its backstop; this issue gives these three caches that backstop. ### What changes - Access rules: a timer reloads the whole rule set every 60 s (`ReloadAsync`; the table is small and flat, as the class summary says). - Zones: a new hosted service in `Ninlil.Dns.Server.Authoritative/Cache/` runs every 60 s and only detects changes: 1. It reads the enabled zones and the records of the answerable ones with the two queries `AuthoritativeZoneCache.StartAsync` already runs (`:45-60`). 2. It compares each zone with the cached `CachedZone`: the zone row fields the caches use, and the record set by id and content. `AuthoritativeZoneCache` gets a read-only accessor for this. 3. For each zone added, changed or removed it calls `AuthoritativeZoneCache.ReloadZoneAsync` and `SignedZoneCache.ReloadZoneAsync`, the pair the event subscribers use. Detection data is never written into a cache. A reload reads fresh from the primary, so a local change made between the detection read and the reload is never undone. An unchanged zone is not touched, so a signed zone is re-signed only when it changed. - Detection reads may use `CreateReplicaReadScope` (the age-reload rule in AGENTS.md "Read replicas"); the reload methods keep reading the primary. Update the comments at `AuthoritativeZoneCache.cs:33-35,144-146`, `SignedZoneCache.cs:71-73` and `DnsAccessControlRuleCache.cs:77-79`, which say "never on a timer". - The backstop reloads caches only. It must not publish `DnsZoneChangedEvent` or start NOTIFY, PTR sync or webhooks; README.md:4199-4204 stays true. - Interval: a constant 60 s, like the other caches. Use the injected `TimeProvider` so tests can drive it. No new option. - A benchmark under `src/dotnet/benchmarks/Ninlil.Benchmarks/Dns/` measures one detection pass at Large (1,000 zones plus one of 50,000 records) on SQLite and PostgreSQL. Copy the numbers into the PR. - README.md:5092-5098 and 4185-4190: zone and access-rule changes made on another instance that shares the database show up after at most 60 seconds, plus the replica lag limit. #76 later adds the ValKey bound to the same text. ### Acceptance - [ ] Authoritative.Tests, red first: two `AuthoritativeZoneCache` and `SignedZoneCache` pairs on one SQLite file; a record written straight through the repository (as another instance would) is answered by the second cache after the fake time advances 61 s. An unchanged signed zone is not signed again (count signing calls). A deleted zone disappears. - [ ] AccessControl.Tests, red first: a rule added through the repository is in effect after 61 s of fake time. - [ ] A test proves the backstop publishes no `DnsZoneChangedEvent`. - [ ] `dotnet test src/dotnet/tests/Ninlil.Dns.Server.Authoritative.Tests`, `src/dotnet/tests/Ninlil.Dns.Server.AccessControl.Tests` and `src/dotnet/tests/Ninlil.Web.Tests` (DI wiring) pass. - [ ] No schema, API or option change. ### Source INT.md #71 and Q-INT-5; README.md:4185-4204, 5086-5098; DEDUPE.md §2. Owner decision 2026-10-31 (Q-INT-5): "60 s TTL backstop now, as a post-release-fixes issue".
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#50
No description provided.