Repository navigation
fix: run maintenance pool deposit inside a transaction - #474
Emmzydice1 wants to merge 1 commit into
Conversation
…entire-app-uses-isnotempty
|
@Emmzydice1 is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Emmzydice1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
4b1f4a4 to
cfb7a4b
Compare
cfb7a4b to
96808ae
Compare
|
Warning Possible malicious code: please review before merging. An automated security scan flagged files in this pull request that appear to contain malicious code. Code like this can run automatically when a project is opened in an editor or its dependencies are installed, so it could compromise the machine of anyone who checks out this branch. Automated scans can be wrong, so this may be a false positive. Maintainers: please review the flagged files carefully before merging, on GitHub in your browser rather than by checking out the branch. The malicious part is often hidden far off to the right of an ordinary-looking line, so scroll sideways through each file. @Emmzydice1: this pull request adds or changes these files, possibly without your knowledge. Malware like this spreads by adding itself to repositories on machines it has infected, so your machine might be compromised. Please undo these changes in this pull request, and don't open or run other projects on that machine until you've checked it. Flagged files at commit Only merge once you're confident these files are safe. ℹ️ Posted automatically by Drips Wave. Questions? Contact support@drips.network. |
Overview
This PR fixes
MaintenancePoolService.deposit(), which currently throwsPessimisticLockTransactionRequiredErroron every call because theSELECT ... FOR UPDATEintroduced in #275 runs on the plain injected repository outside any transaction. The read-lock-fund-update sequence is now wrapped in a singledataSource.transaction(...), so the pessimistic lock is valid and actually covers the subsequent escrow funding, conditionalupdate(... escrowId IS NULL ...)andincrement()calls.Related Issue
Changes
🔒 Transactional deposit
[MODIFY]
src/maintenance-pool/maintenance-pool.service.tsdeposit()now runs its read-lock-fund-update sequence insidethis.dataSource.transaction(async (manager) => { ... }).SELECT ... FOR UPDATEusesmanager.getRepository(MaintenancePool)instead of the plain injected repository, so the pessimistic lock executes with an active transaction.update({ id, escrowId: IsNull() }, ...)compare-and-set and theincrement()write also go through the transactionalmanager, keeping the lock held across the whole sequence.DataSourceis injected into the service so the transaction can be opened.[MODIFY]
src/maintenance-pool/maintenance-pool.service.spec.tscreateQueryBuildermock so the locked read is served through the transactional manager.deposit()runs insidedataSource.transaction(...)and no longer executes the pessimistic lock on the non-transactional repository.[MODIFY]
src/main.tsDataSourceprovider needed byMaintenancePoolServicefor the new transaction wrapper.Verification Results
deposit()no longer throwsPessimisticLockTransactionRequiredErrordataSource.transaction(...)update(... escrowId IS NULL ...)compare-and-set preservedCloses #457