Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0039755Openbravo ERPI. Performancepublic2018-12-04 15:262018-12-17 20:39
Sandrahuguet 
Sandrahuguet 
normalmajorhave not tried
closedfixed 
0
 
3.0PR19Q1 
alostale
Core
No
0039755: It would be nice to have a method to use lock "FOR NO KEY UPDATE"
It would be nice to have a method to use lock "FOR NO KEY UPDATE", because "FOR UPDATE" in PostgreSQL is too aggressive.
- In order to easily simulate the 2 transactions are processed at same time it is necessary to set a break-point just after execution of following code :

financialAccount.setCurrentBalance(financialAccount.getCurrentBalance().subtract(transaction.getDepositAmount()).add(transaction.getPaymentAmount()));

- Go to Payment In and create a payment:
  Organization: F&B España - Region Norte
  Received From: Alimentos y Supermercados, S.A
  Payment Method: Transferencia
  Deposit To: Cuenta de Banco - EUR
  Amount: 100
  In Add details - > Overpayment Action: Leave the credit to be used later
  Done and execution should be stopped in previous break-point

- Open "new incognito window" in Chrome and access
  Go to Payment In and create a new payment:
  Organization: F&B España - Region Norte
  Received From: Restaurantes Luna Llena, S.A.
  Payment Method: Transferencia
  Deposit To: Cuenta de Banco - EUR
  Amount: 200
  Click in add details, the popup does not open, save the header is locked
This is required for PostgreSQL as a workaround until a newer Hibernate version implements HHH-13135 [1].

[1] https://hibernate.atlassian.net/browse/HHH-13135 [^]
Performance
depends on backport 00397563.0PR18Q4.1 closed Sandrahuguet It would be nice to have a method to use lock "FOR NO KEY UPDATE" 
depends on backport 00397573.0PR18Q3.4 closed Sandrahuguet It would be nice to have a method to use lock "FOR NO KEY UPDATE" 
blocks defect 0039672 closed Sandrahuguet Improve contention problems in fin_financial_account 
Issue History
2018-12-04 15:26SandrahuguetNew Issue
2018-12-04 15:26SandrahuguetAssigned To => Sandrahuguet
2018-12-04 15:26SandrahuguetModules => Core
2018-12-04 15:26SandrahuguetTriggers an Emergency Pack => No
2018-12-04 15:28SandrahuguetTag Attached: Performance
2018-12-04 15:28SandrahuguetRelationship addedblocks 0039672
2018-12-04 15:29SandrahuguetStatusnew => scheduled
2018-12-05 13:20SandrahuguetReview Assigned To => alostale
2018-12-05 15:21hgbotCheckin
2018-12-05 15:21hgbotNote Added: 0108285
2018-12-05 15:21hgbotStatusscheduled => resolved
2018-12-05 15:21hgbotResolutionopen => fixed
2018-12-05 15:21hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/18fd96916ab517067b233cfba9f2f54c70ce3cde [^]
2018-12-05 17:23hgbotCheckin
2018-12-05 17:23hgbotNote Added: 0108298
2018-12-05 17:32alostaleNote Added: 0108300
2018-12-05 17:32alostaleStatusresolved => closed
2018-12-05 17:32alostaleFixed in Version => 3.0PR19Q1
2018-12-10 16:15SandrahuguetNote Added: 0108365
2018-12-10 16:15SandrahuguetStatusclosed => new
2018-12-10 16:15SandrahuguetResolutionfixed => open
2018-12-10 16:15SandrahuguetFixed in Version3.0PR19Q1 =>
2018-12-10 16:16SandrahuguetNote Added: 0108366
2018-12-11 08:12hgbotCheckin
2018-12-11 08:12hgbotNote Added: 0108379
2018-12-11 08:12hgbotStatusnew => resolved
2018-12-11 08:12hgbotResolutionopen => fixed
2018-12-11 08:12hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/18fd96916ab517067b233cfba9f2f54c70ce3cde [^] => http://code.openbravo.com/erp/devel/pi/rev/e893c16b5687c6bd83456b837b55c0e77a9c6b7f [^]
2018-12-11 13:29alostaleNote Added: 0108387
2018-12-11 13:29alostaleOS30 =>
2018-12-11 13:29alostaleOS VersionOpenbravo Appliance 14.04 =>
2018-12-11 13:29alostaleProposed Solution updated
2018-12-11 13:30alostaleNote Deleted: 0108387
2018-12-11 13:30alostaleOS0 =>
2018-12-11 13:30alostaleProposed Solution updated
2018-12-11 15:40alostaleNote Added: 0108398
2018-12-11 15:40alostaleStatusresolved => closed
2018-12-11 15:40alostaleFixed in Version => 3.0PR19Q1
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108513
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108515
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108517
2018-12-13 12:12hgbotCheckin
2018-12-13 12:12hgbotNote Added: 0108579
2018-12-13 12:35hgbotCheckin
2018-12-13 12:35hgbotNote Added: 0108580
2018-12-14 11:44hgbotCheckin
2018-12-14 11:44hgbotNote Added: 0108607
2018-12-14 16:04hudsonbotCheckin
2018-12-14 16:04hudsonbotNote Added: 0108623
2018-12-14 16:04hudsonbotCheckin
2018-12-14 16:04hudsonbotNote Added: 0108624
2018-12-14 16:04hudsonbotCheckin
2018-12-14 16:04hudsonbotNote Added: 0108626
2018-12-17 14:38hgbotCheckin
2018-12-17 14:38hgbotNote Added: 0108643
2018-12-17 20:39hudsonbotCheckin
2018-12-17 20:39hudsonbotNote Added: 0108657

Notes
(0108285)
hgbot   
2018-12-05 15:21   
Repository: erp/devel/pi
Changeset: 18fd96916ab517067b233cfba9f2f54c70ce3cde
Author: Sandra Huguet <sandra.huguet <at> openbravo.com>
Date: Tue Dec 04 15:42:37 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/18fd96916ab517067b233cfba9f2f54c70ce3cde [^]

Fixed issue 39755 added in OBDAL lockForNoKeyUpdate

new lockForNoKeyUpdate method to allow the use "FOR NO KEY UPDATE",
because "FOR UPDATE" in PostgreSQL is too aggressive.

---
M src/org/openbravo/dal/service/OBDal.java
---
(0108298)
hgbot   
2018-12-05 17:23   
Repository: erp/devel/pi
Changeset: 1c1d34a46d47bd88ecdaeeda7e84e00d9c313ec0
Author: Sandra Huguet <sandra.huguet <at> openbravo.com>
Date: Wed Dec 05 17:17:46 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/1c1d34a46d47bd88ecdaeeda7e84e00d9c313ec0 [^]

related to issue 39755 code review changes

Not necessary to return the id. Only creates the lock.
Use createNativeQuery and improve code.

---
M src/org/openbravo/dal/service/OBDal.java
---
(0108300)
alostale   
2018-12-05 17:32   
core reviewed + tested in Oracle and PostgreSQL. In both cases:
* Lock is correctly acquired (concurrent threads wait the one with the lock to release it in order to continue).
* Acquiring a record doesn't prevent insertions in other entities with a FK to that record (locking BP an creating an Order for that BP is now possible in PG)
(0108365)
Sandrahuguet   
2018-12-10 16:15   
reopen in order to improve lockForNoKeyUpdate method
(0108366)
Sandrahuguet   
2018-12-10 16:16   
Discussion thread open by ALO in Hibernate forums about pessimistic write locks being too aggressive in PostgreSQL [1].

[1] https://discourse.hibernate.org/t/too-aggressive-pessimistic-write-lock-in-postgresql/1824 [^] [^]
(0108379)
hgbot   
2018-12-11 08:12   
Repository: erp/devel/pi
Changeset: e893c16b5687c6bd83456b837b55c0e77a9c6b7f
Author: Sandra Huguet <sandra.huguet <at> openbravo.com>
Date: Mon Dec 10 16:26:15 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/e893c16b5687c6bd83456b837b55c0e77a9c6b7f [^]

fixed issue 39755 change lockForNoKeyUpdate to return the instance with the lock

*Retrieves an object from the database getting a lock "for no key update" for the indicated
object. Change method name, parameters and return.
*Improve and modify the javadoc with the required changes.

---
M src/org/openbravo/dal/service/OBDal.java
---
(0108398)
alostale   
2018-12-11 15:40   
code reviewed + tested + added automatic test cases

https://code.openbravo.com/erp/devel/pi/rev/7e4c318ad6a32159a18d3de6a070cd12f6705217 [^]
(0108513)
hudsonbot   
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: https://code.openbravo.com/erp/devel/main/rev/470e3cd384c5 [^]
Maturity status: Test
(0108515)
hudsonbot   
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: https://code.openbravo.com/erp/devel/main/rev/470e3cd384c5 [^]
Maturity status: Test
(0108517)
hudsonbot   
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: https://code.openbravo.com/erp/devel/main/rev/470e3cd384c5 [^]
Maturity status: Test
(0108579)
hgbot   
2018-12-13 12:12   
Repository: erp/devel/pi
Changeset: 2df0dc2f8b0834aeeb5cc605e424c72c7263bb93
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Dec 13 12:07:51 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/2df0dc2f8b0834aeeb5cc605e424c72c7263bb93 [^]

related with issue 39755: prevent time based thread syncrhonization in tests

  Time based synchronization is error-prone and can cause false positives.

  Synchronizing events now with CountDownLatch.

---
M src-test/src/org/openbravo/test/dal/DalLockingTest.java
---
(0108580)
hgbot   
2018-12-13 12:35   
Repository: erp/devel/pi
Changeset: 9b27c5a81726ff17cf81cc382fe7d9d87a96f974
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Dec 13 12:35:23 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/9b27c5a81726ff17cf81cc382fe7d9d87a96f974 [^]

related with issue 39755: fail if timeout is reached
  + raname function

---
M src-test/src/org/openbravo/test/dal/DalLockingTest.java
---
(0108607)
hgbot   
2018-12-14 11:44   
Repository: erp/devel/pi
Changeset: 2da162a5e21339af4a8662733fc9a45744d997a5
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Fri Dec 14 11:43:52 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/2da162a5e21339af4a8662733fc9a45744d997a5 [^]

related with issue 39755: preventing false test positives

  T1 and T2 could finish exactly at the same time, now the chances are reduced
  by adding a short delay to T2 after finalization. Also synchronizing on exectionOrder

---
M src-test/src/org/openbravo/test/dal/DalLockingTest.java
---
(0108623)
hudsonbot   
2018-12-14 16:04   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/d4b3ed34e1c8 [^]
Maturity status: Test
(0108624)
hudsonbot   
2018-12-14 16:04   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/d4b3ed34e1c8 [^]
Maturity status: Test
(0108626)
hudsonbot   
2018-12-14 16:04   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/d4b3ed34e1c8 [^]
Maturity status: Test
(0108643)
hgbot   
2018-12-17 14:38   
Repository: erp/devel/pi
Changeset: 7aada5d51e104d56dfe7f9f05898ce43569546c0
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Mon Dec 17 13:59:23 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/7aada5d51e104d56dfe7f9f05898ce43569546c0 [^]

related with issue 39755: give some time to complete the thread

---
M src-test/src/org/openbravo/test/dal/DalLockingTest.java
---
(0108657)
hudsonbot   
2018-12-17 20:39   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/79c941a6a880 [^]
Maturity status: Test