question

Upvotes
3 0 0 3

EMA Java user dispatcher thread deadlock

I'm using ema-3.5.0.1.jar with user dispatch mode.

The application sometimes deadlocks when it starts up. The deadlock comes from dispatcher threads. How long would it take to fix it? Is there a workaround? Below is the thread dump of relevant threads

"dispatcher-0" - Thread t@56
   java.lang.Thread.State: WAITING
        at java.base@11/jdk.internal.misc.Unsafe.park(Native Method)
        - waiting to lock <79b42f53> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) owned by "dispatcher-2" t@60
        at java.base@11/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:885)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:917)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1240)
        at java.base@11/java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:267)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.submitChannel(Reactor.java:1989)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.encodeIntoBufferAndWrite(WlStream.java:748)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.sendCloseMsg(WlStream.java:793)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.timeout(WlStream.java:305)
        at app//com.thomsonreuters.upa.valueadd.reactor.Watchlist.timeout(Watchlist.java:328)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.processWorkerEvent(Reactor.java:2681)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.dispatchChannel(Reactor.java:1972)
        at app//com.thomsonreuters.upa.valueadd.reactor.ReactorChannel.dispatch(ReactorChannel.java:559)
        at app//com.thomsonreuters.ema.access.OmmBaseImpl.rsslReactorDispatchLoop(OmmBaseImpl.java:1336)
        at app//com.thomsonreuters.ema.access.OmmBaseImpl.dispatch(OmmBaseImpl.java:598)
        at app//com.thomsonreuters.ema.access.OmmConsumerImpl.dispatch(OmmConsumerImpl.java:185)
        at app//...
        at java.base@11/java.lang.Thread.run(Thread.java:834)

   Locked ownable synchronizers:
        - locked <1e9a6ed3> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

        - locked <60869d82> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

        - locked <9440f7d> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
"dispatcher-2" - Thread t@60
   java.lang.Thread.State: WAITING
        at java.base@11/jdk.internal.misc.Unsafe.park(Native Method)
        - waiting to lock <1e9a6ed3> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) owned by "dispatcher-0" t@56
        at java.base@11/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:885)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:917)
        at java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1240)
        at java.base@11/java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:267)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.submitChannel(Reactor.java:1989)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.encodeIntoBufferAndWrite(WlStream.java:748)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.sendCloseMsg(WlStream.java:793)
        at app//com.thomsonreuters.upa.valueadd.reactor.WlStream.timeout(WlStream.java:305)
        at app//com.thomsonreuters.upa.valueadd.reactor.Watchlist.timeout(Watchlist.java:328)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.processWorkerEvent(Reactor.java:2681)
        at app//com.thomsonreuters.upa.valueadd.reactor.Reactor.dispatchChannel(Reactor.java:1972)
        at app//com.thomsonreuters.upa.valueadd.reactor.ReactorChannel.dispatch(ReactorChannel.java:559)
        at app//com.thomsonreuters.ema.access.OmmBaseImpl.rsslReactorDispatchLoop(OmmBaseImpl.java:1336)
        at app//com.thomsonreuters.ema.access.OmmBaseImpl.dispatch(OmmBaseImpl.java:598)
        at app//com.thomsonreuters.ema.access.OmmConsumerImpl.dispatch(OmmConsumerImpl.java:185)
        at app//...
        at java.base@11/java.lang.Thread.run(Thread.java:834)

   Locked ownable synchronizers:
        - locked <79b42f53> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

        - locked <75883433> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

        - locked <6da685c> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apijava
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Hi @ahmire.kailer,

Can you please point us to which EMA sample is causing this issue so the development team can confirm it is an issue within the library? Thanks.

Hi @nick.zincone.1

The code is similar to example130 and example410 combined.

In summary:

  • User dispatch mode
  • Multiple consumers with the same user name
  • Multiple threads calling OmmConsumer.registerClient() (registerClient is never invoked by dispatcher threads, dispatcher threads only decode)
  • Long dispatch timeout - OmmConsumer.dispatch(Long.MAX_VALUE) (not sure if this is the best way to wait indefinitely for data, it not please advise)

Hello @ahmire.kailer

I found that you have summitted this issue as issue #151 on GitHub. Did you have a chance to test the work around that suggested by the Dev team?

Upvotes
9.7k 49 38 60

Hi @ahmire.kailer,

In order for the development team to fix a problem within the library, they will need to reproduce the error. Because this isn't a specific example they released that is causing an issue, but instead a hybrid example you put together, you will need to provide the example for them to replicate and show it is an issue within the library, not your application. Ideally, if you can narrow down your example to a minimal code segment, this will allow them to determine where the issue is.

The EMA Project has an issue section that will allow you to report your finding within the library within GitHub.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
3 0 0 3

Hi @nick.zincone.1

I tried to reproduce the problem using much simplified code without success. I then downgraded back to ema-3.4.0.1.jar , it hasn't deadlocked so far. I had deadlock problems with 3.4 using API dispatch, there're suggestions that deadlock could be avoided by using user dispatch and it indeed worked. I upgraded to 3.5 last week thinking it would be better. I'll use 3.4 for now. If I manage to come up with a simple example that could reproduce the problem, I'll put it here.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
11.5k 16 7 10
The issue has been submitted as part of issue #149 on GitHub.
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea