M
M
mystdeim2016-07-08 16:08:52
Java
mystdeim, 2016-07-08 16:08:52

How does singleton locking work on a cluster?

There is this thing:

@Singleton
public class RecoveryWorker {
    @Schedule(minute = "*/1", hour = "*", persistent = false)
    public void run() {
        // тут происходят тяжелые запросы к базе  ~ 2c
        ...
    }
    ...
}


Launched several wildfly instances configured on the same oracle base, began to catch the following error:

ERROR [org.jboss.as.ejb3] (EJB default - 10) JBAS014120: Error invoking timeout for timer: [id=66ed65c4-3a2d-4343-870d-5f7a46a7742c timedObjectId=com.package.Worker auto-timer?:true persistent ?:false [email protected]950e6 initialExpiration=null intervalDuration(in milli sec)=0 nextExpiration=Wed Jun 15 00:01:00 CEST 2016 timerState=IN_TIMEOUT info=null: javax. ejb.ConcurrentAccessTimeoutException: JBAS014373: EJB 3.1 PFD2 4.8.5.5.1 concurrent access timeout on [email protected] - could not obtain lock within 5000MILLISECONDS

Is there some built-in mechanism at the base level that the second instance cannot enter the critical section? How is the problem solved when you need to have Singleton on multiple servers?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Smirnov, 2016-07-09
@mystdeim

How is the problem solved when you need to have Singleton on multiple servers?

PS Concerning option 1 . If the work of singletons is not related to the processing of database records, they can still be synchronized in the same way. Create an entry in any table (for example, in a table of some system settings) and synchronize singletons on it.

S
sirs, 2016-07-08
@sirs

Doesn't work at all. See here and here
Is the transaction not right for you? Or distributed transactions ala XA Transactions?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question