server: registry watcher reloads on its first fingerprint observation (#1238)
The watcher's first poll baselined the fingerprint without reloading, so a route published between the router's startup reload and the first 2s tick (exactly how the tunnel gateway publishes) was silently never served until some later registry change moved the fingerprint. Reload on the first observation too — one redundant reload at startup is the cost of closing the gap. Found while porting the router for titogo, which has carried this fix since.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 file changed,
+5
−5
router.go+5 −5
diff --git a/router.go b/router.go| index a47ff3b..5d9c5a6 100644 |
| --- a/router.go |
| +++ b/router.go |
| @@ -368,8 +368,12 @@ func runRouter(args []string) { |
| COALESCE(SUM(rowid*17 + LENGTH(status)*3 + LENGTH(socket)),0) FROM routes`).Scan(&fp) |
| return fp, err |
| } |
| + // No baseline-only first tick: the first observed fingerprint also |
| + // triggers a reload, so a route published between the router's startup |
| + // reload and this poll (the tunnel gateway publishes exactly that way) |
| + // can't be silently baselined away. One redundant reload at startup is |
| + // the cost of closing that gap. |
| var last string |
| - first := true |
| errs := 0 |
| for range time.Tick(2 * time.Second) { |
| fp, err := poll() |
| @@ -381,10 +385,6 @@ func runRouter(args []string) { |
| continue |
| } |
| errs = 0 |
| - if first { |
| - last, first = fp, false |
| - continue |
| - } |
| if fp == last { |
| continue |
| } |