You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "dcapwell (via GitHub)" <gi...@apache.org> on 2024/06/18 20:31:47 UTC
[PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
dcapwell opened a new pull request, #3379:
URL: https://github.com/apache/cassandra/pull/3379
(no comment)
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645029369
##########
src/java/org/apache/cassandra/service/accord/AccordService.java:
##########
@@ -430,57 +442,76 @@ public long repair(@Nonnull Seekables keysOrRanges, long epoch, long queryStartN
return barrier(keysOrRanges, epoch, queryStartNanos, timeoutNanos, barrierType, isForWrite, repairSyncPoint(allNodes));
}
- private static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
{
return new ReadTimeoutException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
{
return new ReadPreemptedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private long doWithRetries(LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
+ @VisibleForTesting
+ static ReadExhaustedException newBarrierExhausted(TxnId txnId, boolean global)
+ {
+ //TODO (usability): not being able to show the txn is a bad UX, this becomes harder to trace back in logs
+ return new ReadExhaustedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, ImmutableMap.of());
+ }
+
+ @VisibleForTesting
+ static boolean isTimeout(Throwable t)
+ {
+ return t instanceof Timeout || t instanceof ReadTimeoutException || t instanceof Preempted || t instanceof ReadPreemptedException;
+ }
+
+ @VisibleForTesting
+ static long doWithRetries(Blocking blocking, LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
{
// Since we could end up having the barrier transaction or the transaction it listens to invalidated
- RuntimeException existingFailures = null;
+ Throwable existingFailures = null;
Long success = null;
- long backoffMillis = 0;
+ long backoffMillis = initialBackoffMillis;
for (int attempt = 0; attempt < retryAttempts; attempt++)
{
- try
- {
- Thread.sleep(backoffMillis);
Review Comment:
Mostly refactored to make the tests easier (as they count calls to sleep) and make it clear *when* we backoff; which is only when the type of error is expected.
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645208045
##########
src/java/org/apache/cassandra/service/accord/AccordService.java:
##########
@@ -430,57 +442,83 @@ public long repair(@Nonnull Seekables keysOrRanges, long epoch, long queryStartN
return barrier(keysOrRanges, epoch, queryStartNanos, timeoutNanos, barrierType, isForWrite, repairSyncPoint(allNodes));
}
- private static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
{
return new ReadTimeoutException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
{
return new ReadPreemptedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private long doWithRetries(LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
+ @VisibleForTesting
+ static ReadExhaustedException newBarrierExhausted(TxnId txnId, boolean global)
+ {
+ //TODO (usability): not being able to show the txn is a bad UX, this becomes harder to trace back in logs
+ return new ReadExhaustedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, ImmutableMap.of());
+ }
+
+ @VisibleForTesting
+ static boolean isTimeout(Throwable t)
+ {
+ return t instanceof Timeout || t instanceof ReadTimeoutException || t instanceof Preempted || t instanceof ReadPreemptedException;
Review Comment:
if its jvm-dtest there is a function to retry read/writes (assuming they are idempotent, else we fail)... both are timeouts from a users point of view...
##########
src/java/org/apache/cassandra/service/accord/exceptions/ReadExhaustedException.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.service.accord.exceptions;
+
+import java.util.Map;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.exceptions.RequestFailureReason;
+import org.apache.cassandra.locator.InetAddressAndPort;
+
+public class ReadExhaustedException extends ReadFailureException
Review Comment:
I saw other code paths that use it as well, but they are not user facing; `CoordinateGloballyDurable` (background task), and `FetchCoordinator` (bootstrap / streaming of ranges)
##########
src/java/org/apache/cassandra/service/accord/exceptions/ReadExhaustedException.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.service.accord.exceptions;
+
+import java.util.Map;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.exceptions.RequestFailureReason;
+import org.apache.cassandra.locator.InetAddressAndPort;
+
+public class ReadExhaustedException extends ReadFailureException
Review Comment:
I didn't want to touch those as the coverage is mostly via `BurnTest` so subtle changes can take a long time to detect issues.
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645026476
##########
src/java/org/apache/cassandra/net/Verb.java:
##########
@@ -335,8 +335,8 @@ public enum Verb
ACCORD_GET_EPHMRL_READ_DEPS_REQ (162, P2, writeTimeout, IMMEDIATE, () -> GetEphmrlReadDepsSerializers.request, AccordService::verbHandlerOrNoop, ACCORD_GET_EPHMRL_READ_DEPS_RSP),
ACCORD_GET_MAX_CONFLICT_RSP (163, P2, writeTimeout, IMMEDIATE, () -> GetMaxConflictSerializers.reply, RESPONSE_HANDLER ),
ACCORD_GET_MAX_CONFLICT_REQ (164, P2, writeTimeout, IMMEDIATE, () -> GetMaxConflictSerializers.request, AccordService::verbHandlerOrNoop, ACCORD_GET_MAX_CONFLICT_RSP),
- ACCORD_FETCH_DATA_RSP (145, P2, repairTimeout,IMMEDIATE, () -> FetchSerializers.reply, RESPONSE_HANDLER ),
- ACCORD_FETCH_DATA_REQ (146, P2, repairTimeout,IMMEDIATE, () -> FetchSerializers.request, AccordService::verbHandlerOrNoop, ACCORD_FETCH_DATA_RSP ),
+ ACCORD_FETCH_DATA_RSP (145, P2, writeTimeout,IMMEDIATE, () -> FetchSerializers.reply, RESPONSE_HANDLER ),
Review Comment:
spoke with @bdeggleston about this in slack, this timeout is too large and using an unrelated config (bootstrap and repair are not the same thing). This isn't 100% related to this patch as its from my topology fix patch, but trying to pull out bug fixes to make reviews easier
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645033471
##########
src/java/org/apache/cassandra/service/accord/AccordService.java:
##########
@@ -430,57 +442,76 @@ public long repair(@Nonnull Seekables keysOrRanges, long epoch, long queryStartN
return barrier(keysOrRanges, epoch, queryStartNanos, timeoutNanos, barrierType, isForWrite, repairSyncPoint(allNodes));
}
- private static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
{
return new ReadTimeoutException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
{
return new ReadPreemptedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private long doWithRetries(LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
+ @VisibleForTesting
+ static ReadExhaustedException newBarrierExhausted(TxnId txnId, boolean global)
+ {
+ //TODO (usability): not being able to show the txn is a bad UX, this becomes harder to trace back in logs
+ return new ReadExhaustedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, ImmutableMap.of());
+ }
+
+ @VisibleForTesting
+ static boolean isTimeout(Throwable t)
+ {
+ return t instanceof Timeout || t instanceof ReadTimeoutException || t instanceof Preempted || t instanceof ReadPreemptedException;
+ }
+
+ @VisibleForTesting
+ static long doWithRetries(Blocking blocking, LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
{
// Since we could end up having the barrier transaction or the transaction it listens to invalidated
- RuntimeException existingFailures = null;
+ Throwable existingFailures = null;
Long success = null;
- long backoffMillis = 0;
+ long backoffMillis = initialBackoffMillis;
for (int attempt = 0; attempt < retryAttempts; attempt++)
{
- try
- {
- Thread.sleep(backoffMillis);
- }
- catch (InterruptedException e)
- {
- if (existingFailures != null)
- e.addSuppressed(existingFailures);
- throw e;
- }
- backoffMillis = backoffMillis == 0 ? initialBackoffMillis : Math.min(backoffMillis * 2, maxBackoffMillis);
try
{
success = action.getAsLong();
break;
}
catch (RequestExecutionException | CoordinationFailed newFailures)
{
- existingFailures = Throwables.merge(existingFailures, newFailures);
+ existingFailures = FailureAccumulator.append(existingFailures, newFailures, AccordService::isTimeout);
+
+ try
+ {
+ blocking.sleep(backoffMillis);
+ }
+ catch (InterruptedException e)
+ {
+ if (existingFailures != null)
+ e.addSuppressed(existingFailures);
+ throw e;
+ }
+ backoffMillis = Math.min(backoffMillis * 2, maxBackoffMillis);
}
+ // if an unknown/unexpected error happens retry stops right away
}
if (success == null)
{
checkState(existingFailures != null, "Didn't have success, but also didn't have failures");
- throw existingFailures;
+ Throwables.throwIfUnchecked(existingFailures);
+ throw new RuntimeException(existingFailures);
Review Comment:
this is possible on the JVM, but super tacky to hit this case... you either do this *outside* of javac or trick javac... In the common case (most likely 100%) we will return from the previous line
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "aweisberg (via GitHub)" <gi...@apache.org>.
aweisberg commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645186798
##########
src/java/org/apache/cassandra/service/accord/exceptions/ReadExhaustedException.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.service.accord.exceptions;
+
+import java.util.Map;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.exceptions.RequestFailureReason;
+import org.apache.cassandra.locator.InetAddressAndPort;
+
+public class ReadExhaustedException extends ReadFailureException
Review Comment:
We can only hit exhausted for reads and specifically barriers?
##########
src/java/org/apache/cassandra/service/accord/AccordService.java:
##########
@@ -430,57 +442,83 @@ public long repair(@Nonnull Seekables keysOrRanges, long epoch, long queryStartN
return barrier(keysOrRanges, epoch, queryStartNanos, timeoutNanos, barrierType, isForWrite, repairSyncPoint(allNodes));
}
- private static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierTimeout(TxnId txnId, boolean global)
{
return new ReadTimeoutException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
+ @VisibleForTesting
+ static ReadTimeoutException newBarrierPreempted(TxnId txnId, boolean global)
{
return new ReadPreemptedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, txnId.toString());
}
- private long doWithRetries(LongSupplier action, int retryAttempts, long initialBackoffMillis, long maxBackoffMillis) throws InterruptedException
+ @VisibleForTesting
+ static ReadExhaustedException newBarrierExhausted(TxnId txnId, boolean global)
+ {
+ //TODO (usability): not being able to show the txn is a bad UX, this becomes harder to trace back in logs
+ return new ReadExhaustedException(global ? ConsistencyLevel.ANY : ConsistencyLevel.QUORUM, 0, 0, false, ImmutableMap.of());
+ }
+
+ @VisibleForTesting
+ static boolean isTimeout(Throwable t)
+ {
+ return t instanceof Timeout || t instanceof ReadTimeoutException || t instanceof Preempted || t instanceof ReadPreemptedException;
Review Comment:
I literally just encountered the Preempted == timeout issue in my testing today.
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3379:
URL: https://github.com/apache/cassandra/pull/3379#discussion_r1645034786
##########
test/distributed/org/apache/cassandra/distributed/test/accord/AccordBootstrapTest.java:
##########
@@ -267,7 +267,7 @@ public void bootstrapTest() throws Throwable
StreamListener.listener.forSession(session -> {
Assert.assertEquals(node3Addr, session.peer.getAddress());
Assert.assertEquals(0, session.getNumRequests());
- Assert.assertTrue(session.getNumTransfers() > 0);
+ Assert.assertTrue(session.getNumKeyspaceTransfers() > 0);
Review Comment:
I punted on trying to fix the test... we actually don't stream anything....
##########
test/unit/org/apache/cassandra/repair/LocalSyncTaskTest.java:
##########
@@ -171,7 +171,7 @@ private static void assertNumInOut(StreamPlan plan, int expectedIncoming, int ex
StreamCoordinator coordinator = plan.getCoordinator();
StreamSession session = Iterables.getOnlyElement(coordinator.getAllStreamSessions());
assertEquals(expectedIncoming, session.getNumRequests());
- assertEquals(expectedOutgoing, session.getNumTransfers());
+ assertEquals(expectedOutgoing, session.getNumKeyspaceTransfers());
Review Comment:
I punted on trying to fix the test... we actually don't stream anything....
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] ExecuteSyncPoint and Fetch now throw Timeout if all sub-errors are Ti… [cassandra]
Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell merged PR #3379:
URL: https://github.com/apache/cassandra/pull/3379
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org