You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ascherbakoff (via GitHub)" <gi...@apache.org> on 2024/05/06 11:33:23 UTC
[PR] IGNITE-22130 Fix retries. [ignite-3]
ascherbakoff opened a new pull request, #3704:
URL: https://github.com/apache/ignite-3/pull/3704
[This patch fixes retry logic according to IGNITE-22130](https://issues.apache.org/jira/browse/IGNITE-22130)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1593876125
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TransactionExceptionMapperProvider.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.ignite.internal.tx;
+
+import static org.apache.ignite.internal.lang.IgniteExceptionMapper.unchecked;
+
+import com.google.auto.service.AutoService;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.internal.lang.IgniteExceptionMapper;
+import org.apache.ignite.internal.lang.IgniteExceptionMappersProvider;
+import org.apache.ignite.internal.replicator.exception.ReplicationException;
+import org.apache.ignite.tx.TransactionException;
+
+/**
+ * Transaction module exception mapper.
+ */
+@AutoService(IgniteExceptionMappersProvider.class)
Review Comment:
:+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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1597416986
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
> I disagree. The whole exception design is based on error codes. Checking error codes is more clean then comparing exception classes.
I disagree, using Java classes that represent an exception is a widespread practice. Error codes are a way to provide the user with an additional clue on critical situations, especially in the case of thin clients that are not supported exceptions.
> No it should not. This error code and related functionality should be removed, because we got retries from client side. I plan to create a ticket for this.
Ok, I got it.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1597416986
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
> I disagree. The whole exception design is based on error codes. Checking error codes is more clean then comparing exception classes.
I disagree, using Java classes that represent an exception is a widespread practice. Error codes are a way to provide the user with an additional clue on critical situations, especially in the case of thin clients that are not supported exceptions.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 closed pull request #3704: IGNITE-22130 Fix retries.
URL: https://github.com/apache/ignite-3/pull/3704
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1593833889
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
I still think that using exception classes is better than error codes, in general.
By the way, should `ACQUIRE_LOCK_TIMEOUT_ERR` be taken into account as well?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1598334234
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
> I disagree, using Java classes that represent an exception is a widespread practice. Error codes are a way to provide the user with an additional clue on critical situations, especially in the case of thin clients that are not supported exceptions.
Looks like we have no agreement here, because changing error code checking to `instanceof ` doesn't make much sense to me. This however have should not block PR changes. Or is this a merge blocker ? We can fix it later then we have strict rules on working with errors.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1594129993
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
>I still think that using exception classes is better than error codes, in general.
I disagree. The whole exception design is based on error codes. Checking error codes is more clean then compartion exception classes.
> By the way, should ACQUIRE_LOCK_TIMEOUT_ERR be taken into account as well?
No it should not. This error code and related functionality should be removed, because we got retries from client side.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "vldpyatkov (via GitHub)" <gi...@apache.org>.
vldpyatkov commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1598649440
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
+ retryExecutor.schedule(
+ // Need to resubmit again to pool which is valid for synchronous IO execution.
+ () -> partitionOperationsExecutor.execute(() -> res.completeExceptionally(errResp.throwable())),
+ RETRY_TIMEOUT_MILLIS, MILLISECONDS);
Review Comment:
If I understood it correctly,, we are holding response for several milliseconds to prevent instantaneous retry.
What will change if we don't do that? Because it is incorrect to delay a response instead of retrying, especially in cases where we don't make the retry again.
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -626,50 +621,71 @@ private <R> CompletableFuture<R> trackingInvoke(
|| request instanceof MultipleRowPkReplicaRequest && ((MultipleRowPkReplicaRequest) request).requestType() != RW_GET_ALL
|| request instanceof SwapRowReplicaRequest;
- if (write && !full) {
- // Track only write requests from explicit transactions.
- if (!transactionInflights.addInflight(tx.id(), false)) {
- return failedFuture(
- new TransactionException(TX_ALREADY_FINISHED_ERR, format(
- "Transaction is already finished [tableName={}, partId={}, txState={}].",
- tableName,
- partId,
- tx.state()
- )));
- }
+ if (full) { // Full transaction retries are handled in postEnlist.
+ return replicaSvc.invoke(primaryReplicaAndConsistencyToken.get1(), request);
+ } else {
+ if (write) { // Track only write requests from explicit transactions.
Review Comment:
`} else if (write) {`
This code format is acceptable here.
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1022,6 +1028,10 @@ private static boolean allSchemaVersionsSame(Collection<? extends BinaryRow> row
boolean first = true;
for (BinaryRow row : rows) {
+ if (row == null) {
Review Comment:
It looks like a bug, how is it happening?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1598334234
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
> I disagree, using Java classes that represent an exception is a widespread practice. Error codes are a way to provide the user with an additional clue on critical situations, especially in the case of thin clients that are not supported exceptions.
Looks like we have not agreement here, because changing error code checking to `instanceof ` doesn't make much sense to me. This however have should not block PR changes. Or is this a merge blocker ?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1598334234
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
> I disagree, using Java classes that represent an exception is a widespread practice. Error codes are a way to provide the user with an additional clue on critical situations, especially in the case of thin clients that are not supported exceptions.
Looks like we have no agreement here, because changing error code checking to `instanceof ` doesn't make much sense to me. This however should not block PR changes. Or is this a merge blocker ? We can fix it later then we have strict rules on working with errors.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1594129993
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
>I still think that using exception classes is better than error codes, in general.
I disagree. The whole exception design is based on error codes. Checking error codes is more clean then compartion exception classes.
> By the way, should ACQUIRE_LOCK_TIMEOUT_ERR be taken into account as well?
No it should not. This error code and related functionality should be removed, because we got retries from client side.
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
>I still think that using exception classes is better than error codes, in general.
I disagree. The whole exception design is based on error codes. Checking error codes is more clean then compartion exception classes.
> By the way, should ACQUIRE_LOCK_TIMEOUT_ERR be taken into account as well?
No it should not. This error code and related functionality should be removed, because we got retries from client side.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1594136668
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -59,6 +68,8 @@ public class ReplicaService {
private final ReplicationConfiguration replicationConfiguration;
+ private final ScheduledExecutorService retryExecutor;
Review 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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1594129993
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
>I still think that using exception classes is better than error codes, in general.
I disagree. The whole exception design is based on error codes. Checking error codes is more clean then comparing exception classes.
> By the way, should ACQUIRE_LOCK_TIMEOUT_ERR be taken into account as well?
No it should not. This error code and related functionality should be removed, because we got retries from client side. I plan to create a ticket for this.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "ascherbakoff (via GitHub)" <gi...@apache.org>.
ascherbakoff commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1594129993
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
>I still think that using exception classes is better than error codes, in general.
I disagree. The whole exception design is based on error codes. Checking error codes is more clean then comparing exception classes.
> By the way, should ACQUIRE_LOCK_TIMEOUT_ERR be taken into account as well?
No it should not. This error code and related functionality should be removed, because we got retries from client side.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1593515985
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -59,6 +68,8 @@ public class ReplicaService {
private final ReplicationConfiguration replicationConfiguration;
+ private final ScheduledExecutorService retryExecutor;
Review Comment:
pls add `@Nullable` here
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-22130 Fix retries. [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #3704:
URL: https://github.com/apache/ignite-3/pull/3704#discussion_r1598348015
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaService.java:
##########
@@ -210,7 +225,14 @@ private <R> CompletableFuture<R> sendToReplica(String targetNodeConsistentId, Re
return null;
});
} else {
- res.completeExceptionally(errResp.throwable());
+ if (retryExecutor != null && matchAny(unwrapCause(errResp.throwable()), ACQUIRE_LOCK_ERR, REPLICA_MISS_ERR)) {
Review Comment:
This is definitely not a blocker.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org