Skip to content

Commit 6c5df51

Browse files
committed
Fix result graphs in case of DB stall
Emit an all-zero result set into the result.csv file once per reportIntervalSecs. This ensures that the result data aggregated for use in the report graphs isn't screwed up when the DB system completely freezes for extended periods of time.
1 parent fa976c1 commit 6c5df51

3 files changed

Lines changed: 33 additions & 21 deletions

File tree

src/main/java/com/github/pgsqlio/benchmarksql/jtpcc/jTPCC.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ else if (iDBType.equals("babelfish"))
476476
this.scheduler.at(now + reportIntervalSecs * 1000, jTPCCScheduler.SCHED_REPORT,
477477
new jTPCCTData());
478478
}
479+
this.scheduler.at(now + resultIntervalSecs * 1000, jTPCCScheduler.SCHED_DUMMY_RESULT, new jTPCCTData());
479480

480481
try {
481482
scheduler_thread.join();

src/main/java/com/github/pgsqlio/benchmarksql/jtpcc/jTPCCResult.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,31 @@ public void collect(jTPCCTData tdata) {
9494

9595
long now = System.currentTimeMillis();
9696
if (now >= resultNextDue) {
97-
long second = (resultNextDue - resultStartMS) / 1000;
98-
99-
for (int tt = 0; tt <= jTPCCTData.TT_DELIVERY_BG; tt++) {
100-
jTPCC.csv_result_write(
101-
jTPCCTData.trans_type_names[tt] + "," + second + "," + resCounter[tt].numTrans + ","
102-
+ resCounter[tt].sumLatencyMS + "," + resCounter[tt].minLatencyMS + ","
103-
+ resCounter[tt].maxLatencyMS + "," + resCounter[tt].sumDelayMS + ","
104-
+ resCounter[tt].minDelayMS + "," + resCounter[tt].maxDelayMS + "\n");
105-
106-
resCounter[tt].numTrans = 0;
107-
resCounter[tt].sumLatencyMS = 0;
108-
resCounter[tt].minLatencyMS = 0;
109-
resCounter[tt].maxLatencyMS = 0;
110-
resCounter[tt].sumDelayMS = 0;
111-
resCounter[tt].minDelayMS = 0;
112-
resCounter[tt].maxDelayMS = 0;
113-
}
114-
97+
this.emit(now);
98+
}
99+
}
115100

116-
while (resultNextDue <= now)
117-
resultNextDue += (jTPCC.resultIntervalSecs * 1000);
101+
public void emit(long now) {
102+
long second = (resultNextDue - resultStartMS) / 1000;
103+
104+
for (int tt = 0; tt <= jTPCCTData.TT_DELIVERY_BG; tt++) {
105+
jTPCC.csv_result_write(
106+
jTPCCTData.trans_type_names[tt] + "," + second + "," + resCounter[tt].numTrans + ","
107+
+ resCounter[tt].sumLatencyMS + "," + resCounter[tt].minLatencyMS + ","
108+
+ resCounter[tt].maxLatencyMS + "," + resCounter[tt].sumDelayMS + ","
109+
+ resCounter[tt].minDelayMS + "," + resCounter[tt].maxDelayMS + "\n");
110+
111+
resCounter[tt].numTrans = 0;
112+
resCounter[tt].sumLatencyMS = 0;
113+
resCounter[tt].minLatencyMS = 0;
114+
resCounter[tt].maxLatencyMS = 0;
115+
resCounter[tt].sumDelayMS = 0;
116+
resCounter[tt].minDelayMS = 0;
117+
resCounter[tt].maxDelayMS = 0;
118118
}
119+
120+
while (resultNextDue <= now)
121+
resultNextDue += (jTPCC.resultIntervalSecs * 1000);
119122
}
120123

121124
public void aggregate(jTPCCResult into) {

src/main/java/com/github/pgsqlio/benchmarksql/jtpcc/jTPCCScheduler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class jTPCCScheduler implements Runnable {
1212
private static Logger log = LogManager.getLogger(jTPCCScheduler.class);
1313
public final static int SCHED_TERM_LAUNCH = 0, SCHED_SUT_LAUNCH = 1, SCHED_BEGIN = 2,
1414
SCHED_TERMINAL_DATA = 3, SCHED_DELIVERY_DATA = 4, SCHED_END = 5, SCHED_DONE = 6,
15-
SCHED_TERM_LAUNCH_DONE = 7, SCHED_SUT_LAUNCH_DONE = 8, SCHED_REPORT = 9;
15+
SCHED_TERM_LAUNCH_DONE = 7, SCHED_SUT_LAUNCH_DONE = 8, SCHED_REPORT = 9,
16+
SCHED_DUMMY_RESULT = 10;
1617

1718

1819
private jTPCC gdata;
@@ -24,6 +25,7 @@ public class jTPCCScheduler implements Runnable {
2425
private int avl_max_nodes = 0;
2526
private int avl_max_height = 0;
2627
private Random random;
28+
private jTPCCResult dummy_result;
2729

2830
private long current_trans_count = 0;
2931
private long current_neword_count = 0;
@@ -34,6 +36,7 @@ public jTPCCScheduler(jTPCC gdata) {
3436
this.duration_ms = (gdata.rampupMins + gdata.runMins) * 60000;
3537
this.random = new Random(System.currentTimeMillis());
3638
this.avl_lock = new Object();
39+
this.dummy_result = new jTPCCResult();
3740
}
3841

3942
public void run() {
@@ -152,6 +155,11 @@ public void run() {
152155
this.at(tdata.trans_due + jTPCC.reportIntervalSecs * 1000, SCHED_REPORT, tdata);
153156
break;
154157

158+
case SCHED_DUMMY_RESULT:
159+
dummy_result.emit(tdata.trans_due);
160+
this.at(tdata.trans_due + jTPCC.resultIntervalSecs * 1000, SCHED_DUMMY_RESULT, tdata);
161+
break;
162+
155163
default:
156164
log.error("Scheduler, unknown scheduler code {}", tdata.sched_code);
157165
break;

0 commit comments

Comments
 (0)