Skip to content

Stellar work inside database transaction holds connections for 30+ seconds #75

Description

@DeFiVC

What

Both claimReward and credentialService.mint call invokeContract (which involves network calls to Stellar RPC, simulation, and Horizon submission) INSIDE a db.transaction. The Stellar calls have WRITE_TIMEOUT_MS = 30_000 with retry logic and circuit breaker, meaning a single call could hold a database connection for up to 30+ seconds.

Why

The connection pool has max: 10. Under concurrent load, 10 simultaneous reward claims could exhaust the pool, blocking all other database operations (including health checks, user queries, etc.).

Scope

  • Move Stellar transaction calls outside the database transaction
  • Use a two-phase approach: validate in DB tx, execute Stellar tx, then update DB
  • Or increase pool size and add monitoring

Acceptance Criteria

  • Database connections are not held during Stellar network calls
  • The pool is not exhausted under normal concurrent load
  • The reward/credential flow still maintains consistency

Technical Context

  • File: src/modules/rewards/reward.service.ts, lines 160-308
  • File: src/modules/credentials/credential.service.ts, lines 41-177
  • The invokeContract function in src/stellar/transactions.ts has retry logic with 3 attempts

Activity

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

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions