Skip to content

fix(solana-relay): share a single Knex pool across all routes#14307

Open
dylanjeffers wants to merge 1 commit into
mainfrom
fix/solana-relay-knex-pool-fix
Open

fix(solana-relay): share a single Knex pool across all routes#14307
dylanjeffers wants to merge 1 commit into
mainfrom
fix/solana-relay-knex-pool-fix

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

  • Each route module in solana-relay was calling initializeDiscoveryDb() at import time, creating up to 9 independent Knex pools (default max=10 each) and exhausting the Postgres connection limit under load.
  • Extract a single shared pool into a new src/db.ts module and import it from every route and middleware.

Files changed

  • src/db.ts (new) — single shared initializeDiscoveryDb instance.
  • src/routes/meteora/{swap_coin,swap_coin_quote}.ts
  • src/routes/launchpad/{claim_fees,claim_vested_coins,getKeypair}.ts
  • src/routes/relay/{getAllowedMints,associateExternalWallet}.ts
  • src/middleware/signerRecovery.ts

Net diff: 9 files, +20 / -31 — each touched file drops its local pool initialization in favor of import { db } from '../../db'.

Test plan

  • Type check pedalboard/apps/solana-relay builds clean
  • Local solana-relay boots and serves a request through one DBC and one DAMM v2 route
  • Postgres pg_stat_activity shows a single pool's worth of connections from solana-relay under load (not N×pool)

🤖 Generated with Claude Code

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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

⚠️ No Changeset found

Latest commit: f4dd44c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant