Skip to content

Commit 660e2d9

Browse files
authored
null check postPhase in Worker.run to resolve race condition at terminate (#211)
1 parent 1c43cad commit 660e2d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/com/oltpbenchmark/api/Worker.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ public final void run() {
293293
// that either started during the warmup phase or ended
294294
// after the timer went off.
295295
Phase postPhase = workloadState.getCurrentPhase();
296+
297+
if (postPhase == null) {
298+
// Need a null check on postPhase since current phase being null is used in WorkloadState
299+
// and ThreadBench as the indication that the benchmark is over. However, there's a race
300+
// condition with postState not being changed from MEASURE to DONE yet, so we entered the
301+
// switch. In this scenario, just break from the switch.
302+
break;
303+
}
296304
if (preState == MEASURE && postPhase.getId() == prePhase.getId()) {
297305
latencies.addLatency(transactionType.getId(), start, end, this.id, prePhase.getId());
298306
intervalRequests.incrementAndGet();

0 commit comments

Comments
 (0)