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

Enable optimistic locking

    XMLWordPrintable

Details

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

    Description

      Purpose/Overview:
      Enable optimistic locking for most tables. Seeing a 409 error would be an improvement over modifications that fail quietly and affect data integrity. It will also help us to see how frequent these issues are in production.

      Requirements/Scope:
      Enable optimistic locking with failure for the following tables:
      budget
      transaction
      budget_expense_class
      fund
      group_fund_fiscal_year
      expense_class
      fiscal_year
      fund_type
      groups
      ledger
      ledger_fiscal_year_rollover

      Approach:

      • Add the _version attribute to the matching schemas in acq-models. It might be needed to look beyond the obvious, for instance shared_budget should also have the attribute. Merge that PR first.
      "_version": {
         "type": "integer",
         "description": "Record version for optimistic locking"
       },
      • Change the table definitions in schema.json to add "withOptimisticLocking": "failOnConflict".
      • Return a 409 HTTP code when a conflict occurs, which can be detected by the SQL error code 23F09. For that, modify ResponseUtils$handleFailure and check ((PgException)cause).getCode().
      • Update API and module versions with a major change.

       

      Acceptance criteria:

      • All unit tests and integration tests (finance, orders, cross-modules) pass.
      • The MODFISTO-260 test parallel-update-order-lines-different-orders reports a 409 instead of quietly updating the budgets wrongly.

      TestRail: Results

        Attachments

          1. Budget_exp_class as expected.png
            Budget_exp_class as expected.png
            114 kB
          2. Budget as expected.png
            Budget as expected.png
            139 kB
          3. Exp_class 500 error.png
            Exp_class 500 error.png
            148 kB
          4. Exp_class as expected.png
            Exp_class as expected.png
            180 kB
          5. Fiscal year as expected.png
            Fiscal year as expected.png
            117 kB
          6. Fund as expected.png
            Fund as expected.png
            132 kB
          7. Fund type as expected.png
            Fund type as expected.png
            123 kB
          8. Group_fund as expected.png
            Group_fund as expected.png
            132 kB
          9. Group 500 error.png
            Group 500 error.png
            112 kB
          10. Group as expected.png
            Group as expected.png
            119 kB
          11. Ledger 2 errors.png
            Ledger 2 errors.png
            133 kB

          Issue Links

            Activity

              People

                dennisbridges Dennis Bridges
                damieng Damien Guillaume
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases