fix: use bulk query for getAllNodes to prevent PG pool exhaustion#2404
fix: use bulk query for getAllNodes to prevent PG pool exhaustion#2404
Conversation
Two callers in server.ts used meshtasticManager.getAllNodes() which fires one telemetry query per node via Promise.all. With 216+ nodes this saturates the PostgreSQL connection pool (default 10), causing timeouts. Switch to getAllNodesAsync() which uses a single bulk query for all node uptimes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR ReviewI've analyzed this PR that fixes PostgreSQL pool exhaustion issues with large meshes (216+ nodes). Here's my comprehensive review: Todo List:
✅ Code Quality & ImplementationExcellent fix approach! The changes are minimal, targeted, and address the root cause effectively: Lines changed:
Root cause analysis is spot-on:
✅ Performance ImpactSignificant improvement:
✅ Security ConsiderationsNo security concerns:
✅ Correctness & Edge CasesImplementation looks solid:
|
Remove the old getAllNodes() that fired one telemetry query per node. Update test mocks to use getAllNodesAsync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR ReviewI've analyzed this PR that fixes PostgreSQL pool exhaustion issues with large meshes (216+ nodes). Here's my comprehensive review: Todo List:
✅ Code Quality & ImplementationExcellent fix approach! The changes are minimal, targeted, and address the root cause effectively: Lines changed:
Root cause analysis is spot-on:
✅ Performance ImpactSignificant improvement:
✅ Security ConsiderationsNo security concerns:
✅ Correctness & Edge CasesImplementation looks solid:
|
Summary
Fixes PostgreSQL connection pool timeout errors on meshes with many nodes (216+).
meshtasticManager.getAllNodes()fires onegetLatestTelemetryForTypequery per node viaPromise.all. With 216 nodes, this creates 216 concurrent DB queries that exhaust the pg-pool (default 10 connections), causingtimeout exceeded when trying to connecterrors.server.tsto usegetAllNodesAsync()which does a single bulk query for all node uptimes./api/nodes(every page load) and unread counts (frequent polling)Changes
src/server/server.tsgetAllNodes()→getAllNodesAsync()Test plan
npx vitest run— 3070 tests passnpm run build— no TypeScript errors🤖 Generated with Claude Code