Skip to content

fix: consolidate solana-relay Knex connection pools#14308

Open
dylanjeffers wants to merge 3 commits into
mainfrom
fix/solana-relay-db-pool-exhaustion
Open

fix: consolidate solana-relay Knex connection pools#14308
dylanjeffers wants to merge 3 commits into
mainfrom
fix/solana-relay-db-pool-exhaustion

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

Consolidate the solana-relay service's Knex connection pools into a single shared singleton to prevent Postgres connection exhaustion under load.

Root Cause

The solana-relay service had 9 separate route/middleware files each calling initializeDiscoveryDb(config.discoveryDbConnectionString) at module scope. Each call creates an independent Knex pool with a default max of 10 connections, allowing up to ~90 connections to be open simultaneously from a single service instance. Under load this exhausts the Postgres connection limit and causes downstream failures.

Fix

  • Added a new src/db.ts that exports a single shared Knex instance built from the same connection string.
  • Updated all 8 consumers (routes + middleware) to import db from the shared singleton instead of creating their own pool:
    • src/routes/meteora/swap_coin.ts
    • src/routes/meteora/swap_coin_quote.ts
    • src/routes/launchpad/claim_fees.ts
    • src/routes/launchpad/claim_vested_coins.ts
    • src/routes/launchpad/getKeypair.ts
    • src/routes/relay/getAllowedMints.ts
    • src/routes/relay/associateExternalWallet.ts
    • src/middleware/signerRecovery.ts

After this change the service holds a single pool (max ~10 connections by default) regardless of how many route modules use the database.

Test plan

  • npx tsc --noEmit in packages/discovery-provider/plugins/pedalboard/apps/solana-relay succeeds (no new errors introduced)
  • Smoke test the affected routes against a running discovery DB to confirm queries still resolve
  • Verify in staging that the service maintains a single connection pool under concurrent load

🤖 Generated with Claude Code

dylanjeffers and others added 3 commits May 8, 2026 14:42
Instruments three key contest interactions following the existing
'Remix Contest:' event prefix and {remixContestId, trackId} property
shape used by the host/pick-winners events:

  - REMIX_CONTEST_VIEW: contest page/screen first resolves trackId+eventId
  - REMIX_CONTEST_ENTER: user taps Enter Contest / Upload Remix
  - REMIX_CONTEST_VIEW_SUBMISSIONS: user opens the submissions tab

Mobile submissions-tab firing uses useFocusedTab from
react-native-collapsible-tab-view because the contest tabs mount
eagerly (lazy: false) — a plain mount effect would fire even for
users who only view the Details tab.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…t sections

Bug 1 (web): Align static explore section visibility with SearchResults render
condition — hide sections when inputValue is set (during debounce window) in
addition to when showSearchResults is true, so Premium and other filters applied
via the filter pills always suppress unfiltered curated sections.

Bug 2 (web): Guard empty-state tile behind !isPending in AlbumResultsPage and
PlaylistResultsPage so the NoResultsTile is not shown while the query is still
in its initial loading phase, preventing a spurious empty-state flash when
combining "Downloads Available" + "Electronic" genre filters.

Bug 3 (mobile): Include category !== 'all' in the showSearch guard on the
explore screen so tapping a content-type pill (Tracks, Albums, etc.) immediately
shows the filtered SearchResults without requiring a second filter to be added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion

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: b621141

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