Skip to content

fix: SRV probe restarted by a host rename could expire without probing - #526

Merged
keepsimple1 merged 2 commits into
mainfrom
fix/issue-506-probe-restart
Oct 25, 2026
Merged

keepsimple1 merged 2 commits into
mainfrom
fix/issue-506-probe-restart

Conversation

@keepsimple1

@keepsimple1 keepsimple1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Fixes #506.

Problem

The test case test_name_conflict_3 fails now and then: server3 never renames its instance, so server1 and server3 both announce the same instance name and the client sees only 2 distinct services instead of 3. Server3's SRV probe finishes without sending a single probe after the host rename. Server1 never gets a probe for the new SRV, so it never defends the name.

Details

A host rename happens when the hostname’s address record (A, or AAAA for IPv6) conflicts with another host’s. In #506, server3’s conflict3_host.local. A record clashed with server1’s, so the host became conflict3_host-2.local.. It then clashed again with server2’s and became conflict3_host-3.local..

The SRV gets pulled in because its rdata names the host as its target. When the host is renamed, update_hostname rewrites the SRV’s target to the new name. That changes the SRV’s data, so its probe restarts, and that restart is the step the bug broke.

Root cause

The bug is in DnsRegistry::update_hostname. A host rename restarts the SRV probe that names the host, but it only moved start_time and left next_send alone. In the #506 log, server3 lost a tiebreak on the SRV name, which sets next_send = now + 1s. When the host rename then restarted the probe at now + rand(0..250ms), next_send was later than start_time + 750ms. So the next check_probing found the probe already expired and moved the renamed SRV (host conflict3_host-3) to active without ever sending a probe for it. Server1 never saw a probe it could answer with conflicting rdata. That fits the log: probe ... finished: move 2 records to active with no found conflict ... TYPE_SRV, and no (3) anywhere.

Where the lost tiebreak comes from: a daemon also receives its own looped-back probes. After a host rename, an older echo with host conflict3_host.local. compares greater than our new conflict3_host-2.local. (. > -), so the daemon "loses" a tiebreak against itself. That's a separate wart, left as a follow-up. With this fix it only costs a 1 s delay and no longer skips probing.

Changes

  • update_hostname resets next_send along with start_time on restart, and returns true so the caller adds a timer at the new probe time.
  • Unit test test_update_hostname_restarts_probe_send.
  • test_name_conflict_3: server3's monitor now waits for the SRV NameChange (instance rename) instead of breaking on the first NameChange, which is usually the A/host rename.

`DnsRegistry::update_hostname` restarted an in-flight SRV probe by moving
its `start_time` but left `next_send` alone. After a lost tiebreak
`next_send` is a full second ahead, past `start_time + 750ms`, so the
next `check_probing` found the probe already expired and moved the
renamed SRV to active without ever probing it. The peer that owns the
instance name never got a chance to answer, and two daemons announced
the same instance name. This is the flaky `test_name_conflict_3`.

Reset `next_send` with `start_time` and return true so the caller adds
a timer at the new probe time.

Also make `test_name_conflict_3` wait for server3's SRV (instance)
`NameChange`, not the first `NameChange`, which is usually the host
rename.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@keepsimple1
keepsimple1 force-pushed the fix/issue-506-probe-restart branch from d014188 to e57c18d Compare October 25, 2026 04:06
@keepsimple1
keepsimple1 force-pushed the fix/issue-506-probe-restart branch from d014188 to 1b832b7 Compare October 25, 2026 04:33
@keepsimple1
keepsimple1 marked this pull request as ready for review October 25, 2026 04:36
@keepsimple1 keepsimple1 added the bug Something isn't working label Oct 25, 2026
@keepsimple1 keepsimple1 changed the title fix: SRV probe restarted by a host rename could expire without probing (#506) fix: SRV probe restarted by a host rename could expire without probing Oct 25, 2026
@keepsimple1
keepsimple1 merged commit 5e55075 into main Oct 25, 2026
4 checks passed
@keepsimple1
keepsimple1 deleted the fix/issue-506-probe-restart branch October 25, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Probe answers are dropped by the 1s multicast rate limit; flaky test_name_conflict_3

1 participant