Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry fixes #82

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ private static void writeHistograms(Results r) {

sb.append(StringUtil.bold("Unknown Status Transactions:")).append("\n").append(r.getUnknown()).append("\n\n");

sb.append(StringUtil.bold("Zero Rows Transactions:")).append("\n").append(r.getZeroRows()).append("\n\n");

if (!r.getAbortMessages().isEmpty()) {
sb.append("\n\n").append(StringUtil.bold("User Aborts:")).append("\n").append(r.getAbortMessages());
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/oltpbenchmark/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class Results {
private final Histogram<TransactionType> retry = new Histogram<>(false);
private final Histogram<TransactionType> error = new Histogram<>(false);
private final Histogram<TransactionType> retryDifferent = new Histogram<>(false);
private final Histogram<TransactionType> zeroRows = new Histogram<>(true);
private final Map<TransactionType, Histogram<String>> abortMessages = new HashMap<>();
private final FeaturebenchAdditionalResults featurebenchAdditionalResults = new FeaturebenchAdditionalResults();

Expand Down Expand Up @@ -84,6 +85,10 @@ public Histogram<TransactionType> getRetryDifferent() {
return retryDifferent;
}

public Histogram<TransactionType> getZeroRows() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print number of zero_rows to the command line o/p just like rejected transactions? It will help while running workloads manually

return zeroRows;
}

public FeaturebenchAdditionalResults getFeaturebenchAdditionalResults() {
return featurebenchAdditionalResults;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/oltpbenchmark/ThreadBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ private Results runRateLimitedMultiPhase() {
results.getAbort().putAll(txnTypes, 0);
results.getError().putAll(txnTypes, 0);
results.getRetryDifferent().putAll(txnTypes, 0);
results.getZeroRows().putAll(txnTypes, 0);

for (Worker<?> w : workers) {
results.getUnknown().putHistogram(w.getTransactionUnknownHistogram());
Expand All @@ -336,6 +337,7 @@ private Results runRateLimitedMultiPhase() {
results.getAbort().putHistogram(w.getTransactionAbortHistogram());
results.getError().putHistogram(w.getTransactionErrorHistogram());
results.getRetryDifferent().putHistogram(w.getTransactionRetryDifferentHistogram());
results.getZeroRows().putHistogram(w.getTransactionZeroRowsHistogram());
results.getFeaturebenchAdditionalResults().setJsonResultsList(w.featurebenchAdditionalResults.getJsonResultsList());
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/oltpbenchmark/api/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public abstract class Worker<T extends BenchmarkModule> implements Runnable {
private final Histogram<TransactionType> txnAbort = new Histogram<>();
private final Histogram<TransactionType> txnRetry = new Histogram<>();
private final Histogram<TransactionType> txnErrors = new Histogram<>();
private final Histogram<TransactionType> txnZeroRows = new Histogram<>();
private final Histogram<TransactionType> txtRetryDifferent = new Histogram<>();
protected Connection conn = null;
private WorkloadState workloadState;
Expand Down Expand Up @@ -171,6 +172,9 @@ public final Histogram<TransactionType> getTransactionRetryDifferentHistogram()
return (this.txtRetryDifferent);
}

public final Histogram<TransactionType> getTransactionZeroRowsHistogram() {
return (this.txnZeroRows);
}
/**
* Stop executing the current statement.
*/
Expand Down Expand Up @@ -452,7 +456,7 @@ protected final void doWork(DatabaseType databaseType, TransactionType transacti
conn.rollback();

if (isRetryable(ex)) {
LOG.debug(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()), ex);
LOG.debug(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()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to remove ex from the exception log?


status = TransactionStatus.RETRY;

Expand Down Expand Up @@ -482,6 +486,7 @@ protected final void doWork(DatabaseType databaseType, TransactionType transacti
case RETRY -> this.txnRetry.put(transactionType);
case RETRY_DIFFERENT -> this.txtRetryDifferent.put(transactionType);
case ERROR -> this.txnErrors.put(transactionType);
case ZERO_ROWS -> this.txnZeroRows.put(transactionType);
}

}
Expand Down Expand Up @@ -516,6 +521,7 @@ private boolean isRetryable(SQLException ex) {
// MySQL ER_LOCK_WAIT_TIMEOUT
return true;
} else if(errorCode > 0 && !sqlState.isEmpty()) {
// Added by Yugabyte to retry on all errors
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,19 @@ protected TransactionStatus executeWork(Connection conn, TransactionType txnType
List<UtilToMethod> baseUtils = query.getBaseUtils();
int count = query.getCount();
for (int i = 0; i < count; i++) {
for (int j = 0; j < baseUtils.size(); j++) {
for (int j = 0; j < baseUtils.size(); j++)
stmt.setObject(j + 1, baseUtils.get(j).get());
}
if (query.isSelectQuery()) {
ResultSet rs = stmt.executeQuery();
int countSet = 0;
while (rs.next()) {
countSet++;
}
if (countSet == 0) {
isRetry = true;
}
while (rs.next()) countSet++;
if (countSet == 0) return TransactionStatus.ZERO_ROWS;
} else {
int updatedRows = stmt.executeUpdate();
if (updatedRows == 0) {
isRetry = true;
}
if (updatedRows == 0) return TransactionStatus.ZERO_ROWS;
}
}
}
if (isRetry)
return TransactionStatus.RETRY;

} catch (ClassNotFoundException | InvocationTargetException
| InstantiationException | IllegalAccessException |
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/oltpbenchmark/types/TransactionStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ public enum TransactionStatus {
/**
* Transaction encountered an error and was not retried
*/
ERROR
ERROR,

/**
* Query returned ZERO_ROWS
*/
ZERO_ROWS
}
7 changes: 7 additions & 0 deletions src/main/java/com/oltpbenchmark/util/ResultWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ public Map<String, Object> writeDetailedSummary(PrintStream os) {
Map<String, Object> detailedSummaryMap = new TreeMap<>();
Map<String, Object> metadata = new TreeMap<>();
metadata.put("yaml_version", expConf.getString("yaml_version", "v1.0"));
metadata.put("Completed Transactions", results.getSuccess().getSampleCount());
metadata.put("Aborted Transactions", results.getAbort().getSampleCount());
metadata.put("Rejected Transactions (Server Retry)", results.getRetry().getSampleCount());
metadata.put("Rejected Transactions (Retry Different)", results.getRetryDifferent().getSampleCount());
metadata.put("Unexpected SQL Errors", results.getError().getSampleCount());
metadata.put("Unknown Status Transactions", results.getUnknown().getSampleCount());
metadata.put("Zero Rows Returned", results.getZeroRows().getSampleCount());
detailedSummaryMap.put("metadata", metadata);
detailedSummaryMap.put("Summary", summaryMap);
detailedSummaryMap.put("queries", results.getFeaturebenchAdditionalResults().getJsonResultsList());
Expand Down
13 changes: 12 additions & 1 deletion src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%-5p] %d [%t] %x %c %M - %m%n

# file appender
log4j.appender.FA=org.apache.log4j.FileAppender
log4j.appender.FA.File=debugLog.out
log4j.appender.FA.Threshold=DEBUG
log4j.appender.FA.Append=false
# Define the layout for file appender
log4j.appender.FA.layout=org.apache.log4j.PatternLayout
log4j.appender.FA.layout.conversionPattern=%d [%t] %x %c %M - %m%n
log4j.category.com.oltpbenchmark.api.Worker=DEBUG, FA
log4j.additivity.com.oltpbenchmark.api.Worker=false

log4j.logger.com.oltpbenchmark=INFO
log4j.logger.com.oltpbenchmark.DBWorkload=INFO
log4j.logger.com.oltpbenchmark.ThreadBench=INFO
log4j.logger.com.oltpbenchmark.DistributionStatistics=INFO
log4j.logger.com.oltpbenchmark.api.BenchmarkModule=INFO
log4j.logger.com.oltpbenchmark.api.Loader=INFO
log4j.logger.com.oltpbenchmark.api.Worker=INFO
#log4j.logger.com.oltpbenchmark.api.Worker=INFO
log4j.logger.com.oltpbenchmark.api.Procedure=INFO
log4j.logger.com.oltpbenchmark.catalog.Catalog=INFO
log4j.logger.com.oltpbenchmark.util.ThreadUtil=INFO
Expand Down