| 36627 |
37 d 18 h |
amit |
/trunk/profitmandi-cron/ |
Thrift cleanup: remove ThriftConfig from settings, clean unused Thrift imports
- Removed ThriftConfig from settings.gradle
- TransactionRelatedTasks: removed unused Scan import
- POScheduler: removed unused PurchaseOrder import |
|
/trunk/profitmandi-cron/settings.gradle /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/TransactionRelatedTasks.java /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/purchaseorder/POScheduler.java
|
| 35424 |
191 d 14 h |
amit |
/trunk/ |
Fix order billing vs cancellation race condition with pessimistic locking
Problem:
- Concurrent billing and cancellation of the same order caused data inconsistency
- Money was refunded to wallet while order was also getting billed
Solution:
- Added pessimistic locking (SELECT FOR UPDATE) to prevent concurrent modifications
- Added validation methods to check order state before billing/cancellation
- Optimized billing method to reduce lock duration with pre-fetching
Changes:
- OrderRepository: Added selectByIdForUpdate, selectByOrderIdsForUpdate,
selectByInvoiceNumbersForUpdate, selectAllByTransactionIdForUpdate,
validateOrdersForBilling, validateOrderForRefund methods
- OrderRepositoryImpl: Implemented locking methods with PESSIMISTIC_WRITE
- TransactionServiceImpl: Updated billing methods with locking, fail-fast
validation, pre-fetching to avoid N+1 queries
- ScheduledTasks: Updated removePartialBillingForTransaction with locking
- TransactionRelatedTasks: Updated reverseRTO with locking |
|
/trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ScheduledTasks.java /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/TransactionRelatedTasks.java /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/OrderRepository.java /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/OrderRepositoryImpl.java /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/TransactionServiceImpl.java
|