fix(solana-relay): share a single Knex pool across all routes#14307
Open
dylanjeffers wants to merge 1 commit into
Open
fix(solana-relay): share a single Knex pool across all routes#14307dylanjeffers wants to merge 1 commit into
dylanjeffers wants to merge 1 commit into
Conversation
Each route module was calling initializeDiscoveryDb() on import, creating up to 9 independent connection pools (default max=10 each) and exhausting the Postgres connection limit under load. Extract a single shared pool into src/db.ts and import it from every route and middleware. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
solana-relaywas callinginitializeDiscoveryDb()at import time, creating up to 9 independent Knex pools (defaultmax=10each) and exhausting the Postgres connection limit under load.src/db.tsmodule and import it from every route and middleware.Files changed
src/db.ts(new) — single sharedinitializeDiscoveryDbinstance.src/routes/meteora/{swap_coin,swap_coin_quote}.tssrc/routes/launchpad/{claim_fees,claim_vested_coins,getKeypair}.tssrc/routes/relay/{getAllowedMints,associateExternalWallet}.tssrc/middleware/signerRecovery.tsNet diff: 9 files, +20 / -31 — each touched file drops its local pool initialization in favor of
import { db } from '../../db'.Test plan
pedalboard/apps/solana-relaybuilds cleanpg_stat_activityshows a single pool's worth of connections from solana-relay under load (not N×pool)🤖 Generated with Claude Code