Skip to content

fix(maintenance-pool): drop broken pessimistic lock in deposit (#457) - #470

Open
Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/deposit-pessimistic-lock-457
Open

Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/deposit-pessimistic-lock-457

Conversation

@Proxima84-code

Copy link
Copy Markdown

Resolves #457.

Root Cause

In MaintenancePoolService.deposit(), createQueryBuilder('pool').setLock('pessimistic_write') was executed outside an active transaction. TypeORM throws PessimisticLockTransactionRequiredError when executing pessimistic locks without an active transaction runner, causing all POST /maintenance-pool/:id/deposit requests to crash with HTTP 500. Furthermore, wrapping the entire call in a database transaction would hold database row locks during multi-second Soroban RPC network calls (escrowService.fund).

Fix

  • Dropped the broken pessimistic lock in deposit() and replaced it with a direct findOne() read.
  • Leveraged the existing atomic conditional Compare-And-Set (update({ id, escrowId: null }, { escrowId })), which already handles concurrent first-time deposit races safely without connection starvation.
  • Restored valid syntax in escrow.service.ts and updated maintenance-pool.service.spec.ts.

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@Proxima84-code is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MaintenancePoolService.deposit() always throws PessimisticLockTransactionRequiredError — the #275 SELECT ... FOR UPDATE runs outside any transaction

1 participant