Optimize financial action operations - #719
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR focuses on reducing load and improving reliability for high-volume financial operations by adding idempotency to wallet transfers, optimizing accountant-side “unprocessed” checks, and improving archiving/retry behavior.
Changes:
- Add transfer idempotency via
transferReflookups and duplicate-key recovery to avoid double-applying balance changes. - Optimize accountant unprocessed lookups (COUNT → EXISTS), add targeted partial indexes, and tighten archive candidate selection.
- Improve retry scheduling backoff and archive job batching; extend unit tests to cover the new behaviors.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wallet/wallet-ports/wallet-persister-postgres/src/main/kotlin/co/nilin/opex/wallet/ports/postgres/impl/TransactionManagerImpl.kt | Adds findByTransferRef lookup to support idempotent transfer handling. |
| wallet/wallet-ports/wallet-persister-postgres/src/main/kotlin/co/nilin/opex/wallet/ports/postgres/dao/TransactionRepository.kt | Adds query to fetch transaction id by transfer_ref. |
| wallet/wallet-core/src/test/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImplTest.kt | Adds test to ensure idempotent transfer returns success without side effects. |
| wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/spi/TransactionManager.kt | Extends SPI with findByTransferRef. |
| wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt | Implements idempotency flow + duplicate-key recovery and adds helper to build idempotent results. |
| wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/exc/ConcurrentBalanceChangException.kt | Changes exception to unchecked (RuntimeException). |
| wallet/wallet-app/pom.xml | Adds HikariCP dependency in test scope. |
| accountant/accountant-ports/accountant-persister-postgres/src/test/kotlin/co/nilin/opex/accountant/ports/postgres/FAPersisterImplTest.kt | Adds test verifying retry scheduling uses backoff delay. |
| accountant/accountant-ports/accountant-persister-postgres/src/main/resources/schema.sql | Adds partial indexes for unprocessed lookup and archive candidates. |
| accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/impl/FinancialActionPersisterImpl.kt | Fixes retry scheduling to apply backoff starting from the first retry. |
| accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/impl/FinancialActionLoaderImpl.kt | Replaces COUNT-based unprocessed query with EXISTS-based check (returns 1/0). |
| accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/dao/FinancialActionRepository.kt | Adds EXISTS query and tightens archive candidate selection to exclude parents with unprocessed children. |
| accountant/accountant-app/src/main/kotlin/co/nilin/opex/accountant/app/scheduler/FinancialActionsArchiveJob.kt | Archives in multiple batches per run with a configurable cap. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
AmirRajabii
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.