Skip to content

Commit cca4d5b

Browse files
buptyzcchavdar
authored andcommitted
Fix transaction writer thread exit bug (#102)
* transactionWriter exit bug fix * bind the writerTransaction close into the orlistener close function
1 parent 72331f1 commit cca4d5b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

databus2-relay/databus2-event-producer-or/src/main/java/com/linkedin/databus2/producers/ORListener.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,16 @@ else if (event instanceof TableMapEvent)
716716
_log.info("ORListener Thread done");
717717
doShutdownNotify();
718718
}
719-
720-
public TransactionWriter getTransactionWriter()
719+
720+
public void shutdownAll()
721721
{
722-
return _transactionWriter;
722+
if(this.isAlive())
723+
{
724+
this.shutdown();
725+
}
726+
if (_transactionWriter != null && _transactionWriter.isAlive())
727+
{
728+
_transactionWriter.shutdown();
729+
}
723730
}
724731
}

databus2-relay/databus2-event-producer-or/src/main/java/com/linkedin/databus2/producers/OpenReplicatorEventProducer.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ public void run()
413413
try
414414
{
415415
//should stop orListener first to get the final maxScn used for init open replicator.
416-
if (_orListener.isAlive())
417-
{
418-
_orListener.shutdown();
419-
}
416+
_orListener.shutdownAll();
420417
long maxScn = _maxSCNReaderWriter.getMaxScn();
421418
_startPrevScn.set(maxScn);
422419
initOpenReplicator(maxScn);
@@ -462,14 +459,7 @@ public void run()
462459
_log.error("failed to stop Open Replicator", e);
463460
}
464461
}
465-
if (_orListener.isAlive())
466-
{
467-
_orListener.shutdown();
468-
}
469-
if (_orListener.getTransactionWriter().isAlive())
470-
{
471-
_orListener.getTransactionWriter().shutdown();
472-
}
462+
_orListener.shutdownAll();
473463

474464
_log.info("Event Producer Thread done");
475465
doShutdownNotify();

databus2-relay/databus2-event-producer-or/src/main/java/com/linkedin/databus2/producers/TransactionWriter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public void run()
115115
}
116116
}
117117
}
118+
log.info("transactionWriter thread done!");
119+
doShutdownNotify();
118120
}
119121

120122
}

0 commit comments

Comments
 (0)