Closed vladimirfx closed 6 years ago
Can you provide more data to validate this issue. Better add a simple test case. Simply synchronizing access seems killing to me. Might be a future performance issue!
I have similar stacktraces with frozen threads - nothing else. Reproducible test case for synchronization issues is nearly impossible thing, because hardware is involved (CPU L2/3 cache). Related discussion: https://stackoverflow.com/questions/38761222/hashmap-hang-in-concurrent-access
Performance hit there should be very low if measurable at all. On current JVM's synchronization itself has very low impact if threads do not clash when acquiring monitor. IMHO ConcurrentHashMap is overkill for this usecase.
IMHO I only see need to synchronize the WeakMap not the other ones as handling with those objects should always be in the same Thread. Maybe @gnodet could approve this.
In all TransactionManagerWrapper impls fields such resources and recoverables accessed and modified from:
Definitely it is not same thread.
Close in favor of #10.
As result many JVM freezes with stacks like this:
"schedulerSyncChanges-1" Id=162 in RUNNABLE at java.util.WeakHashMap.transfer(WeakHashMap.java:528) at java.util.WeakHashMap.resize(WeakHashMap.java:493) at java.util.WeakHashMap.put(WeakHashMap.java:466) at java.util.Map.computeIfAbsent(Map.java:958) at org.ops4j.pax.transx.tm.impl.AbstractTransactionManagerWrapper.getTransaction(AbstractTransactionManagerWrapper.java:49) at org.ops4j.pax.transx.connector.impl.GenericConnectionManager.getMci(GenericConnectionManager.java:186) at org.ops4j.pax.transx.connector.impl.GenericConnectionManager.allocateConnection(GenericConnectionManager.java:171) at org.ops4j.pax.transx.connector.impl.GenericConnectionManager.allocateConnection(GenericConnectionManager.java:167) at org.ops4j.pax.transx.jdbc.impl.TransxDataSource.getConnection(TransxDataSource.java:68) at org.ops4j.pax.transx.jdbc.impl.TransxDataSource.getConnection(TransxDataSource.java:59) at sun.reflect.GeneratedMethodAccessor328.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)