8000 Device discovery: per-tenant time budget, log slow and skipped tenants by klehmann · Pull Request #122 · klehmann/MindooDB · GitHub
[go: up one dir, main page]

Skip to content

Device discovery: per-tenant time budget, log slow and skipped tenants - #122

Merged
klehmann merged 1 commit into
mainfrom
fix/device-discovery-tenant-timeout
Nov 20, 2026
Merged

klehmann merged 1 commit into
mainfrom
fix/device-discovery-tenant-timeout

Conversation

@klehmann
Copy link
Copy Markdown
Owner

Requested by Karsten · project thread

Problem

A MindooMail gateway approved on demo-server1 could not join: every POST /device/discover ran for exactly 120 s and then Cloudflare answered 520. /device/challenge and an unsigned /device/discover (401) answer in ~0.1 s, the container did not restart and there was no OOM. The server log shows the discover loading every tenant one after another and never reaching [DeviceDiscovery] Wrapped …, so one tenant's directory.getUserBySigningPublicKey() (for an unknown key it goes through the time-travel directory state) does not return. Which tenant and why is still open; this PR makes the endpoint survive it and names the tenant.

Changes

  • DeviceDiscoveryService.discover: tenants are checked 4 at a time, each within 10 s (DeviceDiscoveryOptions to override). A timed-out tenant is skipped and logged: [DeviceDiscovery] tenant <id>: skipped, no answer within 10000 ms. Lookups ≥ 2 s are logged with their duration.
  • Matches are returned in the server's tenant order, as before.
  • Test: one tenant whose lookup never resolves plus one granted tenant → answer within the budget with the granted tenant, warning logged.

Testing

  • npx jest src/__tests__/DeviceDiscovery.test.ts (5 passed), src/__tests__/ServerCoreInMemory.test.ts (5 passed)
  • tsc --noEmit

Follow-up

Once deployed, the log names the hanging tenant; if it is the tenant the gateway was approved in, the gateway is skipped there too and the directory hang itself needs fixing.


Generated by Claude Code

/device/discover checked every tenant one after another. On a server where
one tenant's directory lookup hangs, the request never answered and
Cloudflare returned 520 after 120 s, so a freshly approved gateway could
never join (seen on demo-server1).

Tenants are now checked four at a time, each within 10 s. A tenant that
does not answer in time is skipped and logged with its id; lookups over
2 s are logged too, to find the culprit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VV3yvzDYWbyjds137B8aXj
@klehmann klehmann self-assigned this Nov 20, 2026
@klehmann
klehmann merged commit 7d713a2 into main Nov 20, 2026
@klehmann
klehmann deleted the fix/device-discovery-tenant-timeout branch November 20, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0