Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0039717Openbravo ERPA. Platformpublic2018-11-29 12:172018-12-11 20:22
normalminorhave not tried
0039717: unnecesary contention to create new documents in UI
It is not possible to create a new document in UI while there is a transaction holding a lock for that same sequence type.

1. In psql execute and keep it open with the transaction active:
  pi=> begin;
  pi=> select AD_Sequence_DocType('466AF4B0136A4A3F9F84129711DA8BD3', '23C59575B9CF467C9620760EB255B389', 'N');
2. Log in as F&B admin
3. Open Sales Order window
4. Click on new
   -> It is not possible to edit the new record, the UI keeps frozen waiting for default values
5. In pgsql execute commit; to finalize the transaction
   -> Now the default values appear and it is possible to continue
The document proposed in UI on new records is just a proposal which is later properly set when saving the record. So there is no need to wait for locks in ad_sequence, it's better to provide a document number already proposed to a different document to fix it afterwards rather than waiting it to be unlocked.
related to defect 0039672 closed Sandrahuguet Improve contention problems in fin_financial_account 
related to defect 0015801 closed adrianromero the system is blocked when run Create AP Expense Invoices 
Issue History
2018-11-29 12:17alostaleNew Issue
2018-11-29 12:17alostaleAssigned To => platform
2018-11-29 12:17alostaleModules => Core
2018-11-29 12:17alostaleTriggers an Emergency Pack => No
2018-11-29 12:17alostaleTag Attached: Performance
2018-11-29 12:17alostaleRelationship addedrelated to 0039672
2018-11-30 11:59alostaleRelationship addedrelated to 0015801
2018-11-30 16:07galderromoIssue Monitored: galderromo
2018-12-03 09:56alostaleAssigned Toplatform => alostale
2018-12-03 09:56alostaleReview Assigned To => vmromanos
2018-12-03 09:57hgbotCheckin
2018-12-03 09:57hgbotNote Added: 0108221
2018-12-03 09:57hgbotStatusnew => resolved
2018-12-03 09:57hgbotResolutionopen => fixed
2018-12-03 09:57hgbotFixed in SCM revision => [^]
2018-12-05 12:00SandrahuguetReview Assigned Tovmromanos => Sandrahuguet
2018-12-05 15:38SandrahuguetNote Added: 0108293
2018-12-05 15:38SandrahuguetStatusresolved => closed
2018-12-05 15:38SandrahuguetFixed in Version => 3.0PR19Q1
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108510

2018-12-03 09:57   
Repository: erp/devel/pi
Changeset: 3ff8ce5616bb33fc8a92b88fd2dfcda41a2b14f4
Author: Asier Lostalé <asier.lostale <at>>
Date: Fri Nov 30 11:55:27 2018 +0100
URL: [^]

fixed bug 39717: unnecesary contention to create new documents in UI

  AD_Sequence_DocType acquired a "FOR UPDATE" lock whenever it was invoked regardless
  whether it updated the sequence number or only returned a number proposal. The
  latter is the the case of proposing document numbers while creating from UI,
  which was forced to be sequentially executed due to this lock.

  AD_Sequence_DocType behavior has been changed to:
   1. If AD_Sequence_DocType is not going to finally update AD_Sequence, no lock
      is acquired.
   2. Acquire the lock only if AD_Sequence is updated. Even this lock has been
      relaxed in PostgreSQL from FOR UPDATE to FOR NO KEY UPDATE, by doing the
      update (which aquires the lock) before doing the select, which now needs
      to know in which case we are in order to properly calculate the actual

  The same applies to AD_Sequence_Doc.

M src-db/database/model/functions/AD_SEQUENCE_DOC.xml
M src-db/database/model/functions/AD_SEQUENCE_DOCTYPE.xml
2018-12-05 15:38   
Code review + testing OK
2018-12-11 20:22   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: [^]
Maturity status: Test