forked from Qortal/qortal
Improve documentation regarding deadlock in EventBus
This commit is contained in:
parent
54bb8ed817
commit
064e12a57b
@ -22,18 +22,25 @@ public enum EventBus {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>WARNING:</b> before calling this method,
|
* <b>WARNING:</b> before calling this method,
|
||||||
* make sure repository holds no locks, e.g. by calling
|
* make sure current thread's repository session
|
||||||
|
* holds no locks, e.g. by calling
|
||||||
|
* <tt>repository.saveChanges()</tt> or
|
||||||
* <tt>repository.discardChanges()</tt>.
|
* <tt>repository.discardChanges()</tt>.
|
||||||
* <p>
|
* <p>
|
||||||
* This is because event listeners might open a new
|
* This is because event listeners might open a new
|
||||||
* repository session which will deadlock HSQLDB
|
* repository session which will deadlock HSQLDB
|
||||||
* if it tries to CHECKPOINT.
|
* if it tries to CHECKPOINT.
|
||||||
* <p>
|
* <p>
|
||||||
* The HSQLDB deadlock occurs because the caller's
|
* The HSQLDB deadlock path is:
|
||||||
* repository session blocks the CHECKPOINT until
|
* <ul>
|
||||||
* their transaction is closed, yet event listeners
|
* <li>write-log <tt>blockchain.log</tt> has grown past CHECKPOINT threshold (50MB)</li>
|
||||||
* new sessions are blocked until CHECKPOINT is
|
* <li>alternatively, another thread has explicitly requested CHECKPOINT</li>
|
||||||
* completed, hence deadlock.
|
* <li>HSQLDB won't begin CHECKPOINT until all pending (SQL) transactions are committed or rolled back</li>
|
||||||
|
* <li>Same thread calls <tt>EventBus.INSTANCE.notify()</tt> <i>before</i> (SQL) transaction closed</li>
|
||||||
|
* <li>EventBus listener (same thread) requests a new repository session via <tt>RepositoryManager.getRepository()</tt></li>
|
||||||
|
* <li>New repository sessions are blocked pending completion of CHECKPOINT</li>
|
||||||
|
* <li>Caller is blocked so never has a chance to close (SQL) transaction - hence deadlock</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public void notify(Event event) {
|
public void notify(Event event) {
|
||||||
List<Listener> clonedListeners;
|
List<Listener> clonedListeners;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user