Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-911

Optimistic locking _version overflow

    XMLWordPrintable

Details

    • Story
    • Status: Closed (View Workflow)
    • TBD
    • Resolution: Done
    • None
    • 33.2.9, 34.0.0
    • None
    • CP: sprint 138
    • 1
    • Core: Platform
    • TBD

    Description

      PostgreSQL allows up to 1000 digits for the _version number: https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL

      JSON has no number restriction: https://www.json.org/json-en.html

      RAML also has no restrictions for the number and integer types: https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#number

      mod-inventory-storage declares _version to be of RAML type integer: https://github.com/folio-org/mod-inventory-storage/blob/v23.0.2/ramls/instance.json#L11

      RMB incorrectly generates Java type Integer in org.folio.rest.jaxrs.model.Instance.java.

      This will result in a parse exception when Integer.MAX_VALUE = 2147483647 is exceeded.

      It takes 68 years when incrementing each second. It takes only 1 year when incrementing 68 times per second.

      There might be stress tests, load tests, performance tests or other tests that update the same instance, holding or item frequently and therefore it might be possible that an overflow occurs.

      Changing the optimistic locking trigger to wrap around from 2147483647 to 0 is the easiest fix:

      (oldvalue::numeric + 1) % 2147483648
      

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases