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
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
What
Both
claimRewardandcredentialService.mintcallinvokeContract(which involves network calls to Stellar RPC, simulation, and Horizon submission) INSIDE adb.transaction. The Stellar calls haveWRITE_TIMEOUT_MS = 30_000with 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
Acceptance Criteria
Technical Context
src/modules/rewards/reward.service.ts, lines 160-308src/modules/credentials/credential.service.ts, lines 41-177invokeContractfunction insrc/stellar/transactions.tshas retry logic with 3 attempts