Openbravo Issue Tracking System - Retail Modules
View Issue Details
0035886Retail ModulesStoreServerpublic2017-04-11 15:182017-06-09 21:09
alostale 
mtaal 
normalmajorhave not tried
closedno change required 
5
 
RR17Q2.1 
mtaal
No
0035886: MobileServerController.getThisServerDefinition creates contention
MobileServerController.getThisServerDefinition method is invoked all the time from many different places. It is synchronized on a singleton class, which in practice, means there is only thread per JVM that can execute it.

This method causes some contention at JVM level.

The situation can become worse in scenarios with overload, if number of DB connections is limited at pool level. Because in some cases, the connection for the thread is borrowed from pool inside this method, this can cause deadlock situations if:

-pool size=1
-thread 1 acquires the connection anywhere
-thread 2 inside this method tries to get a new connection, it cannot get it till thread 1 returns the one it previously borrowed
-thread 1 invokes MobileServerController.getThisServerDefinition
  -> DEADLOCK: it won't be able to execute this method till thread 2 completes it, but it is waiting for thread 1 to release its connection
Can be artificially reproduced by

0. Configure pool as follows:
  db.pool.maxActive=5
  db.pool.maxWait=10000
1. clone https://bitbucket.org/gpscode/butmultiservertests [^]
2. execute wordDay.jmx setting 10 concurrent threads
3. check JVM contention (attached a screenshot from Yourkit)
* Does it make any sense this method to be synchronized?
  - If it does not: remove syncrhonization
  - If it does: what for? would it properly work in a clustered environment?, in any case look for an alternative

* Additionally, always it's invoked a DB query is triggered, to always return the same record. Could we improve it by some caching?
No tags attached.
blocks defect 0035754 closed AugustoMauch MobileServerController.getThisServerDefinition creates contention 
Issue History
2017-05-01 17:24mtaalTypedefect => backport
2017-05-01 17:24mtaalTarget Version => RR17Q2.1
2017-05-01 17:25mtaalAssigned ToAugustoMauch => mtaal
2017-06-09 21:09mtaalNote Added: 0097294
2017-06-09 21:09mtaalStatusscheduled => closed
2017-06-09 21:09mtaalResolutionopen => no change required

Notes
(0097294)
mtaal   
2017-06-09 21:09   
no need to backport, is covered in q3, individual backports will be done to but