Uploaded image for project: 'mod-inventory-storage'
  1. mod-inventory-storage
  2. MODINVSTOR-1025

Race condition in /inventory-storage/bound-withs

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • P4
    • Resolution: Unresolved
    • None
    • None
    • None
    • Sif
    • TBD

    Description

      /inventory-storage/bound-withs assumes that no other process touches the records involved. This cannot be guaranteed and may cause roll backs or unique violation exceptions (race condition).

      The validation, the INSERT and the DELETE should be in the same transaction.

      SELECT count(*) FROM item WHERE id=$1 FOR KEY SHARE;
      SELECT count(*) FROM holdings_record WHERE id in (...) FOR KEY SHARE;
      DELETE FROM bound_with_part 
        WHERE itemId=$1 AND holdingsRecordId NOT IN (...) 
        RETURNING jsonb;
      INSERT INTO bound_with_part (id, jsonb) VALUES ... 
        ON CONFLICT DO NOTHING 
        RETURNING jsonb;
      

      FOR KEY SHARE is needed to prevent a roll-back if some other process wants to delete the item or the holding.
      RETURNING jsonb is needed to return the changed elements for the Kafka messages.

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                julianladisch Julian Ladisch
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:

                  TestRail: Runs

                    TestRail: Cases