Skip to content

Commit

Permalink
null check postPhase in Worker.run to resolve race condition at t…
Browse files Browse the repository at this point in the history
…erminate (cmu-db#211)
  • Loading branch information
mbutrovich authored Jul 20, 2022
1 parent 1c43cad commit 660e2d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/oltpbenchmark/api/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ public final void run() {
// that either started during the warmup phase or ended
// after the timer went off.
Phase postPhase = workloadState.getCurrentPhase();

if (postPhase == null) {
// Need a null check on postPhase since current phase being null is used in WorkloadState
// and ThreadBench as the indication that the benchmark is over. However, there's a race
// condition with postState not being changed from MEASURE to DONE yet, so we entered the
// switch. In this scenario, just break from the switch.
break;
}
if (preState == MEASURE && postPhase.getId() == prePhase.getId()) {
latencies.addLatency(transactionType.getId(), start, end, this.id, prePhase.getId());
intervalRequests.incrementAndGet();
Expand Down

0 comments on commit 660e2d9

Please sign in to comment.