Uploaded image for project: 'iDempiere'
  1. IDEMPIERE-3785

Potential duplicate key and documentno from MSequence

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.1, 5.1
    • Fix Version/s: 5.1
    • Component/s: Core
    • Labels:
    • Environment:

      Oracle database

    • Sprint:

      Description

      MSequence can (and will, under concurrent load) potentially generate duplcate keys or generate a lock.
      I have tracked the problem down to MSequence.getNextID: if the db is PostgreSQL a "for update" clause is appendend after the select, but is missing from oracle code.
      Old Adempiere used a db procedure, wich was using the 'for update' clause. iDempiere doesnt use it anymore.
      This result on duplicate key under concurrent load.

      A similar issue affect MSequencce.getDocumentNoFromSeq, with an additional 'strange' check: if the sequence is for a system document no, no "for update" is appended (not even postgresql). I dont see any valid reason for that behaviour, but i may be missing something. The provided patch fixes that too.

      To recap, the fix contains:
      getNextID: added "for update of" CurrrentNext or CurrentNextSys for oracle db

      getDocumentNoFromSeq:

      1. added "for update of"
      2. Check for 'isoracle' consistent with getNextId check
      3. removed check for system seq, always using "for update"

      Regards,
      Silvano, https://www.freepath.it

        Attachments

          Activity

            People

            • Assignee:
              info FreePath
              Reporter:
              info FreePath
              Tested By:
              Nicolas Micoud
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: