Skip to content

Commit 472d049

Browse files
authored
Write result files after error (#234)
1 parent 979b53b commit 472d049

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

src/main/java/com/oltpbenchmark/BenchmarkState.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public void ackLatencyComplete() {
9292
state = State.MEASURE;
9393
}
9494

95+
public void signalError() {
96+
// A thread died, decrement the count and set error state
97+
notDoneCount.decrementAndGet();
98+
state = State.ERROR;
99+
}
100+
95101
public void startCoolDown() {
96102
state = State.DONE;
97103

src/main/java/com/oltpbenchmark/ThreadBench.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ private Results runRateLimitedMultiPhase() {
205205
}
206206
}
207207

208-
// Go to next phase if this one is complete
209-
if (phaseComplete && !lastEntry) {
208+
// Go to next phase if this one is complete or enter if error was thrown
209+
boolean errorThrown = testState.getState() == State.ERROR;
210+
if ((phaseComplete || errorThrown) && !lastEntry) {
210211
// enters here after each phase of the test
211212
// reset the queues so that the new phase is not affected by the
212213
// queue of the previous one
@@ -355,19 +356,25 @@ private long getInterval(int lowestRate, Phase.Arrival arrival) {
355356

356357
@Override
357358
public void uncaughtException(Thread t, Throwable e) {
358-
359-
// HERE WE HANDLE THE CASE IN WHICH ONE OF OUR WOKERTHREADS DIED
359+
// Here we handle the case in which one of our worker threads died
360360
LOG.error(e.getMessage(), e);
361-
System.exit(-1);
362-
363-
/*
364-
* Alternatively, we could keep an HashMap<Thread,Worker> storing the
365-
* runnable for each thread, so that we can get the latency numbers from
366-
* a thread that died, and either continue or at least report current
367-
* status. (Remember to remove this thread from the list of threads to
368-
* wait for)
369-
*/
370-
361+
// We do not continue with the experiment. Instead, bypass rest of
362+
// phases that were left in the test and signal error state.
363+
// The rest of the workflow to finish the experiment remains the same,
364+
// and partial metrics will be reported (i.e., until failure happened).
365+
synchronized (testState) {
366+
for (WorkloadConfiguration workConf : this.workConfs) {
367+
synchronized (workConf.getWorkloadState()) {
368+
WorkloadState workState = workConf.getWorkloadState();
369+
Phase phase = workState.getCurrentPhase();
370+
while (phase != null) {
371+
workState.switchToNextPhase();
372+
phase = workState.getCurrentPhase();
373+
}
374+
}
375+
}
376+
testState.signalError();
377+
}
371378
}
372379

373380
public static final class TimeBucketIterable implements Iterable<DistributionStatistics> {

src/main/java/com/oltpbenchmark/types/State.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
package com.oltpbenchmark.types;
2222

2323
public enum State {
24-
WARMUP, MEASURE, COLD_QUERY, LATENCY_COMPLETE, DONE, EXIT,
24+
WARMUP, MEASURE, COLD_QUERY, LATENCY_COMPLETE, DONE, EXIT, ERROR
2525
}

0 commit comments

Comments
 (0)