[ https://issues.apache.org/jira/browse/OFBIZ-13153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890415#comment-17890415 ]
Mayank S edited comment on OFBIZ-13153 at 10/17/24 10:58 AM: ------------------------------------------------------------- I am well aware of the demerits of synchronization; however, using synchronized in the getInstance () method of Singleton classes is common practice. 'localContext' in the ServiceDispatcher class is essentially like a singleton map which is storing the dispatch-context objects. We tried making it a ConcurrentHashMap instead of a HashMap but it still didn't fix the issue. Hence, we synchronized the register (DispatchContext) method. I believe this method is called only during start-up/ one time for each tenant dispatcher, and hence the performance implication is not much if we are looking at only one call being affected, amongst thousands to millions of calls. However, if it fails to register the dispatch context once, for some reason, the dispatcher always comes as null for that tenant continuously in each subsequent call, increasing the error-rate. If there is any other solution to this problem, which has been tested and proven with a high load of 200 concurrent users or higher, then please let me know. was (Author: JIRAUSER307429): I am well aware of the demerits of synchronization; however, using synchronized in the getInstance () method of Singleton classes is common practice. 'localContext' in the ServiceDispatcher class is essentially like a singleton map which is storing the dispatch-context objects. We tried making it a ConcurrentHashMap instead of a HashMap but it still didn't fix the issue. Hence, we synchronized the register (DispatchContext) method. I believe this method is called only during start-up/ one time for each tenant dispatcher, and hence the performance implication is not much if we are looking at only one call being affected, amongst thousands to millions of calls. If there is any other solution to this problem, which has been tested and proven with a high load of 200 concurrent users or higher, then please let me know. > "null DispatchContext" issue under high load and concurrency > ------------------------------------------------------------ > > Key: OFBIZ-13153 > URL: https://issues.apache.org/jira/browse/OFBIZ-13153 > Project: OFBiz > Issue Type: Bug > Components: framework/service > Affects Versions: 18.12.16 > Environment: Virtual Machine: > OS: RHEL 8.9 > VCPU: 16 > Total RAM: 64 GB > Heap allocation (Xmx): 8 GB > Reporter: Mayank S > Priority: Major > Labels: performance > Fix For: 18.12.17 > > Original Estimate: 24h > Remaining Estimate: 24h > > While performance-testing Ofbiz 18 under high load (200 concurrent users), we > have observed an intermittent error, stating "null DispatchContext". > While doing more analysis, we realized it is a thread-safety issue, and it > was fixed by adding the 'synchronized' keyword to the following method > signatures in ServiceDispatcher.java: > public static synchronized getInstance (Delegator delegator) > public static synchronized void register (DispatchContext context) -- This message was sent by Atlassian Jira (v8.20.10#820010)