maedhroz commented on code in PR #2150:
URL: https://github.com/apache/cassandra/pull/2150#discussion_r1103043582
##########
test/distributed/org/apache/cassandra/distributed/test/accord/AccordTestBase.java:
##########
@@ -181,29 +191,49 @@ private SimpleQueryResult executeWithRetry0(int count,
Cluster cluster, String c
{
return execute(cluster, check, boundValues);
}
- catch (Throwable t)
+ catch (RuntimeException ex)
{
- if (AssertionUtils.rootCauseIs(Preempted.class).matches(t))
+ if (count <= 10 &&
AssertionUtils.rootCauseIs(Preempted.class).matches(ex))
{
- logger.warn("[Retry attempt={}] Preempted failure for {}",
count, check);
+ logger.warn("[Retry attempt={}] Preempted failure for\n{}",
count, check);
return executeWithRetry0(count + 1, cluster, check,
boundValues);
}
- throw t;
+ throw ex;
}
}
protected SimpleQueryResult executeWithRetry(Cluster cluster, String
check, Object... boundValues)
{
+ check = normalizeStatement(check);
+
// is this method safe?
- cluster.get(1).runOnInstance(() -> {
- TransactionStatement stmt = AccordTestUtils.parse(check);
- if (!isIdempotent(stmt))
- throw new AssertionError("Unable to retry txn that is not
idempotent: cql=" + check);
- });
+
+ if (!isIdempotent(cluster, check))
+ throw new AssertionError("Unable to retry txn that is not
idempotent: cql=\n" + check);
+
return executeWithRetry0(0, cluster, check, boundValues);
}
+ private boolean isIdempotent(Cluster cluster, String cql)
+ {
+ return cluster.get(1).callOnInstance(() -> {
+ String normalized = normalizeStatement(cql);
+ TransactionStatement stmt =
AccordTestUtils.parse(normalizeStatement(normalizeStatement(normalized)));
+ return isIdempotent(stmt);
+ });
+ }
+
+ private static String normalizeStatement(String statement)
Review Comment:
```suggestion
private static String wrapInTxn(String statement)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]