diff --git a/src/main/java/com/oltpbenchmark/LatencyRecord.java b/src/main/java/com/oltpbenchmark/LatencyRecord.java index 0525d23f2..0129e11f5 100644 --- a/src/main/java/com/oltpbenchmark/LatencyRecord.java +++ b/src/main/java/com/oltpbenchmark/LatencyRecord.java @@ -49,8 +49,8 @@ public LatencyRecord(long startNanosecond) { } - public void addLatency(int transType, long startNanosecond, long endNanosecond, int workerId, int phaseId) { - + public void addLatency(int transType, long startNanosecond, long endNanosecond, int workerId, int phaseId, + int transactionStatus) { if (nextIndex == ALLOC_SIZE) { allocateChunk(); @@ -61,8 +61,8 @@ public void addLatency(int transType, long startNanosecond, long endNanosecond, int latencyMicroseconds = (int) ((endNanosecond - startNanosecond + 500) / 1000); - - chunk[nextIndex] = new Sample(transType, startOffsetNanosecond, latencyMicroseconds, workerId, phaseId); + chunk[nextIndex] = new Sample(transType, startOffsetNanosecond, latencyMicroseconds, workerId, phaseId, + transactionStatus); ++nextIndex; lastNanosecond += startOffsetNanosecond; @@ -94,13 +94,16 @@ public static final class Sample implements Comparable { private final int latencyMicrosecond; private final int workerId; private final int phaseId; + private final int transactionStatus; - public Sample(int transactionType, long startNanosecond, int latencyMicrosecond, int workerId, int phaseId) { + public Sample(int transactionType, long startNanosecond, int latencyMicrosecond, int workerId, int phaseId, + int transactionStatus) { this.transactionType = transactionType; this.startNanosecond = startNanosecond; this.latencyMicrosecond = latencyMicrosecond; this.workerId = workerId; this.phaseId = phaseId; + this.transactionStatus = transactionStatus; } public int getTransactionType() { @@ -123,6 +126,10 @@ public int getPhaseId() { return phaseId; } + public int getTransactionStatus() { + return transactionStatus; + } + @Override public int compareTo(Sample other) { long diff = this.startNanosecond - other.startNanosecond; diff --git a/src/main/java/com/oltpbenchmark/api/Worker.java b/src/main/java/com/oltpbenchmark/api/Worker.java index 5506f99c7..b8255a562 100644 --- a/src/main/java/com/oltpbenchmark/api/Worker.java +++ b/src/main/java/com/oltpbenchmark/api/Worker.java @@ -320,7 +320,8 @@ public final void run() { break; } if (preState == MEASURE && postPhase.getId() == prePhase.getId()) { - latencies.addLatency(transactionType.getId(), start, end, this.id, prePhase.getId()); + latencies.addLatency(transactionType.getId(), start, end, this.id, prePhase.getId(), + status.ordinal()); intervalRequests.incrementAndGet(); PrometheusMetrics.TXN_DURATION.labels(this.benchmark.getBenchmarkName(), @@ -476,7 +477,7 @@ protected final TransactionStatus doWork(DatabaseType databaseType, TransactionT String message = String.format( "Retryable SQLException occurred during [%s]... current retry attempt [%d], max retry attempts [%d], sql state [%s], error code [%d].", transactionType, retryCount, maxRetryCount, ex.getSQLState(), ex.getErrorCode()); - + if (logRetries) { LOG.warn(message + " " + ex.getMessage()); } else { @@ -485,17 +486,18 @@ protected final TransactionStatus doWork(DatabaseType databaseType, TransactionT status = TransactionStatus.RETRY; retryCount++; - + if (this.workloadState.getGlobalState() == State.MEASURE) { - errors.addError(ex.getMessage(), parseError(transactionType, ex, retryCount < maxRetryCount)); + errors.addError(ex.getMessage(), + parseError(transactionType, ex, retryCount < maxRetryCount)); } } else { LOG.warn( "SQLException occurred during [{}] and will not be retried. sql state [{}], error code [{}]. {}", transactionType, ex.getSQLState(), ex.getErrorCode(), ex.getMessage()); - + status = TransactionStatus.ERROR; - + if (this.workloadState.getGlobalState() == State.MEASURE) { errors.addError(ex.getMessage(), parseError(transactionType, ex, false)); } @@ -513,7 +515,7 @@ protected final TransactionStatus doWork(DatabaseType databaseType, TransactionT } } - if (this.workloadState.getGlobalState() == State.MEASURE) { + if (this.workloadState.getGlobalState() == State.MEASURE) { switch (status) { case UNKNOWN -> this.txnUnknown.put(transactionType); case SUCCESS -> this.txnSuccess.put(transactionType); diff --git a/src/main/java/com/oltpbenchmark/util/ResultWriter.java b/src/main/java/com/oltpbenchmark/util/ResultWriter.java index 7c308d2d5..bf6c25de0 100644 --- a/src/main/java/com/oltpbenchmark/util/ResultWriter.java +++ b/src/main/java/com/oltpbenchmark/util/ResultWriter.java @@ -26,6 +26,8 @@ import com.oltpbenchmark.api.collectors.DBParameterCollector; import com.oltpbenchmark.api.collectors.DBParameterCollectorGen; import com.oltpbenchmark.types.DatabaseType; +import com.oltpbenchmark.types.TransactionStatus; + import org.apache.commons.cli.CommandLine; import org.apache.commons.configuration2.XMLConfiguration; import org.apache.commons.configuration2.ex.ConfigurationException; @@ -212,7 +214,8 @@ public void writeRaw(List activeTXTypes, PrintStream out) { "Start Time (microseconds)", "Latency (microseconds)", "Worker Id (start number)", - "Phase Id (index in config file)" + "Phase Id (index in config file)", + "Transaction Status" }; out.println(StringUtil.join(",", header)); for (LatencyRecord.Sample s : results.getLatencySamples()) { @@ -226,6 +229,7 @@ public void writeRaw(List activeTXTypes, PrintStream out) { Integer.toString(s.getLatencyMicrosecond()), Integer.toString(s.getWorkerId()), Integer.toString(s.getPhaseId()), + TransactionStatus.values()[s.getTransactionStatus()].toString(), }; out.println(StringUtil.join(",", row)); }