Skip to content

Commit 330c5e7

Browse files
authored
Merge pull request #49 from mongodb-labs/no-endless-loop
SLS-1922 Prevent endless loop upon shutdown
2 parents 6f36042 + 96dcd6a commit 330c5e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ycsb-mongodb/core/src/main/java/site/ycsb/TerminatorThread.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ public void run() {
5151
System.err.println("Maximum time elapsed. Requesting stop for the workload.");
5252
workload.requestStop();
5353
System.err.println("Stop requested for workload. Now Joining!");
54+
long startTime = System.currentTimeMillis();
5455
for (Thread t : threads) {
5556
while (t.isAlive()) {
5657
try {
5758
t.join(waitTimeOutInMS);
59+
60+
long elapsedTime = System.currentTimeMillis() - startTime;
61+
if (elapsedTime > 3 * maxExecutionTime * 1000) {
62+
System.exit(1);
63+
}
5864
if (t.isAlive()) {
5965
System.out.println("Still waiting for thread " + t.getName() + " to complete. " +
6066
"Workload status: " + workload.isStopRequested());

0 commit comments

Comments
 (0)