dcapwell commented on code in PR #1796:
URL: https://github.com/apache/cassandra/pull/1796#discussion_r948448769


##########
src/java/org/apache/cassandra/service/TruncateResponseHandler.java:
##########
@@ -61,24 +62,36 @@ public TruncateResponseHandler(int responseCount)
     public void get() throws TimeoutException
     {
         long timeoutNanos = getTruncateRpcTimeout(NANOSECONDS) - (nanoTime() - 
start);
-        boolean completedInTime;
+        boolean signaled;
         try
         {
-            completedInTime = condition.await(timeoutNanos, NANOSECONDS); // 
TODO truncate needs a much longer timeout
+            signaled = condition.await(timeoutNanos, NANOSECONDS); // TODO 
truncate needs a much longer timeout
         }
         catch (InterruptedException e)
         {
             throw new UncheckedInterruptedException(e);
         }
 
-        if (!completedInTime)
-        {
+        if (!signaled)
             throw new TimeoutException("Truncate timed out - received only " + 
responses.get() + " responses");
-        }
 
-        if (truncateFailingReplica != null)
+        if (!failureReasonByEndpoint.isEmpty())
         {
-            throw new TruncateException("Truncate failed on replica " + 
truncateFailingReplica);
+            int size = failureReasonByEndpoint.size();
+            long timeouts = 
failureReasonByEndpoint.values().stream().filter(RequestFailureReason.TIMEOUT::equals).count();
+            long nonTimeout = size - timeouts;
+            if (nonTimeout <= timeouts)
+            {
+                throw new TimeoutException("Truncate timed out - received only 
" + responses.get() + " responses");
+            }
+            else
+            {
+                StringBuilder sb = new StringBuilder("Truncate failed on 
replicas ");
+                for (Map.Entry<InetAddressAndPort, RequestFailureReason> e : 
failureReasonByEndpoint.entrySet())
+                    sb.append(e.getKey()).append(' 
').append(e.getValue()).append(", ");
+                sb.setLength(sb.length() - 2);
+                throw new TruncateException(sb.toString());

Review Comment:
   this change is causing test failures... switching from `replica` to 
`replicas` and now including the reason... wondering if I should keep the old 
logic; just log 1



-- 
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]

Reply via email to