Uploaded image for project: 'mod-finance-storage'
  1. mod-finance-storage
  2. MODFISTO-304

Lock budgets to update totals

    XMLWordPrintable

Details

    • Story
    • Status: Closed (View Workflow)
    • P3
    • Resolution: Done
    • None
    • 8.2.0
    • None
    • ACQ Sprint 141
    • 2
    • Thunderjet
    • Morning Glory (R2 2022)
    • TBD

    Description

      Purpose/Overview:
      Currently budget updates can conflict when 2 transactions are applied in parallel for the same budget. We can prevent this issue by locking the budgets with Postgres when getting budgets/applying changes/updating them.

      Requirements/Scope:
      Use a Postgres lock in EncumbranceService$updateBudgetsTotals, PaymentCreditService$updateBudgetsTotals, and PendingPaymentService.

      Approach:

      • Use a Postgres transaction. There is already one created in AllOrNothingTransactionService, so we probably don't need to do anything.
      • Use SELECT ... FOR UPDATE when getting the budgets to update (add getBudgetsForUpdate() to budgetService).
      • Make sure the transaction is ended at the end, or rolled back if an error occurs (this is already done in AllOrNothingTransactionService).
      • Use the parallel-update-order-lines-different-orders test from MODFISTO-260.

      Acceptance criteria:

      • parallel-update-order-lines-different-orders never fails anymore.
      • Unit tests and integration tests (finance, orders, invoices, cross-module) pass.

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                Andrei_Makaranka Andrei Makaranka
                damieng Damien Guillaume
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases