You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "JAkutenshi (via GitHub)" <gi...@apache.org> on 2024/09/24 20:44:40 UTC
[PR] IGNITE-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
JAkutenshi opened a new pull request, #4446:
URL: https://github.com/apache/ignite-3/pull/4446
JIRA Ticket: [IGNITE-22036](https://issues.apache.org/jira/browse/IGNITE-22036)
## The goal
## The reason
## The solution
---
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1872550265
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -2248,6 +2256,46 @@ private static PartitionSet extendPartitionSet(@Nullable PartitionSet oldPartiti
return newPartitionSet;
}
+ private void executeIfLocalNodeIsPrimaryForGroup(
Review Comment:
In `TableManager` we do the general logic of rebalance after new pending assignments handling. Before the PR we're looking for RAFT-group leader and then trying to do direct `changePeersAndLearnersAsync` call on leader's client. Now we're looking for primary replica (cited method do this) and then sending the new primary replica request. If somewhy this general approach failed then we're waiting for the failover logic is triggered.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1873048439
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
Added, but it's usage demands `busyLock` guarding then. Also I'm not sure: should I do retries then on L1448-1450? Failure handler looks wrong there.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1875555069
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
Please consider using `org.apache.ignite.internal.util.IgniteUtils#inBusyLockSafe` or `org.apache.ignite.internal.util.IgniteUtils#inBusyLock(org.apache.ignite.internal.util.IgniteSpinBusyLock, java.lang.Runnable)` or similar.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1867581652
##########
modules/catalog-compaction/src/integrationTest/java/org/apache/ignite/internal/catalog/compaction/ItCatalogCompactionTest.java:
##########
@@ -51,14 +51,13 @@
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.tx.Transaction;
import org.apache.ignite.tx.TransactionOptions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Integration tests to verify catalog compaction.
*/
-class ItCatalogCompactionTest extends ClusterPerClassIntegrationTest {
+class ItCatalogCompactionTest extends ClusterPerTestIntegrationTest {
Review Comment:
What's the point in creating cluster per each test?
##########
modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java:
##########
@@ -1252,8 +1254,10 @@ public CompletableFuture<Boolean> invoke(
partitionRaftConfigurer,
view -> new LocalLogStorageFactory(),
ForkJoinPool.commonPool(),
- t -> converter.get().apply(t)
- );
+ t -> converter.get().apply(t),
+ replicaGrpId -> metaStorageManager.get(ZoneRebalanceUtil.pendingPartAssignmentsKey((ZonePartitionId) replicaGrpId))
Review Comment:
I'd rather use static import here in order to eliminate excessive ZoneRebalanceUtil.
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/replication/ChangePeersAndLearnersAsyncReplicaRequest.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.partition.replicator.network.replication;
+
+import org.apache.ignite.internal.network.annotations.Transferable;
+import org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
+import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest;
+
+/**
+ * Request for performing {@link org.apache.ignite.internal.raft.service.RaftGroupService#changePeersAndLearnersAsync} on a primary replica.
+ */
+@Transferable(PartitionReplicationMessageGroup.CHANGE_PEERS_AND_LEARNERS_ASYNC_REPLICA_REQUEST)
+public interface ChangePeersAndLearnersAsyncReplicaRequest extends PrimaryReplicaRequest {
+ /** New peers configuration to rebalance. */
+ BinaryTupleMessage pendingAssignments();
Review Comment:
Please consider using byte[] or
```
@Transferable(MessageGroup.ASSIGNMENTS_MESSAGE)
public interface AssignmentsMessage extends NetworkMessage {
...
}
```
if byte[] array is not convenient.
##########
modules/placement-driver-api/src/testFixtures/java/org/apache/ignite/internal/placementdriver/TestPlacementDriver.java:
##########
@@ -112,8 +112,29 @@ public Supplier<? extends ReplicaMeta> getPrimaryReplicaSupplier() {
return this.primaryReplicaSupplier;
}
- public void setPrimaryReplicaSupplier(Supplier<? extends ReplicaMeta> primaryReplicaSupplier) {
+ /**
+ * Setter for a test primary replica supplier with {@code PRIMARY_REPLICA_ELECTED} event firing that is crucial for some tests internal
+ * logic that depends on the event handling.
+ *
+ * @param primaryReplicaSupplier The supplier that provides {@link TestReplicaMetaImpl} instance with a test primary replica meta
+ * information.
+ */
+ public void setPrimaryReplicaSupplier(Supplier<? extends TestReplicaMetaImpl> primaryReplicaSupplier) {
this.primaryReplicaSupplier = primaryReplicaSupplier;
+
+ TestReplicaMetaImpl replicaMeta = primaryReplicaSupplier.get();
+
+ fireEvent(
+ PrimaryReplicaEvent.PRIMARY_REPLICA_ELECTED,
+ new PrimaryReplicaEventParameters(
+ 0,
Review Comment:
Is that ok to have 0 here?
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/replication/ChangePeersAndLearnersReplicaRequest.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.partition.replicator.network.replication;
+
+import org.apache.ignite.internal.network.annotations.Transferable;
+import org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
+import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest;
+import org.apache.ignite.internal.replicator.message.ReplicaRequest;
+
+/**
+ * Request for performing {@link org.apache.ignite.internal.raft.service.RaftGroupService#changePeersAndLearnersAsync} on a primary replica.
+ */
+@Transferable(PartitionReplicationMessageGroup.CHANGE_PEERS_AND_LEARNERS_REPLICA_REQUEST)
+public interface ChangePeersAndLearnersReplicaRequest extends ReplicaRequest {
+ /** New peers configuration to rebalance. */
+ BinaryTupleMessage pendingAssignments();
Review Comment:
Why do you use BinaryTupleMessage?
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871762720
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
Hm, `ReplicaStateManager` don't have one. And it doesn't have (yet) `shutdown` method for turning busy lock on. There are options:
1. Do we really need it?
2. We may reuse `ReplicaManager`'s one?
3. Or add the special one with `shutdown()` that will call on `ReplicaManager#stopAsync`?
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1869000669
##########
modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java:
##########
@@ -305,14 +305,16 @@ private static boolean recoverable(Throwable t) {
* @return Future that is completed when all subscription messages to peers are sent.
*/
public CompletableFuture<Void> subscribeLeader(LeaderElectionListener callback) {
- assert !serverEventHandler.isSubscribed() : "The node already subscribed";
+ if (serverEventHandler.isSubscribed()) {
Review Comment:
That's is bit messy. The fact that we once set callback to serverEventHandler and if it was already initialised - add it to eventsClientListener while we also add serverEventHandler to eventsClientListener. That should be refactored. Please create jira and add TODO.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871891119
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -589,6 +602,67 @@ private CompletableFuture<Void> processTxRecoveryMessage(TxRecoveryMessage reque
return triggerTxRecovery(txId, senderId);
}
+ private CompletableFuture<Void> processChangePeersAndLearnersReplicaRequest(ChangePeersAndLearnersAsyncReplicaRequest request) {
+ TablePartitionId replicaGrpId = (TablePartitionId) request.groupId().asReplicationGroupId();
+
+ RaftGroupService raftClient = raftCommandRunner instanceof RaftGroupService
+ ? (RaftGroupService) raftCommandRunner
+ : ((RaftGroupService) ((ExecutorInclinedRaftCommandRunner) raftCommandRunner).decoratedCommandRunner());
+
+ return raftClient.refreshAndGetLeaderWithTerm()
+ .exceptionally(throwable -> {
+ throwable = unwrapCause(throwable);
+
+ if (throwable instanceof TimeoutException) {
+ LOG.info(
+ "Node couldn't get the leader within timeout so the changing peers is skipped [grp={}].",
+ replicaGrpId
+ );
+
+ return LeaderWithTerm.NO_LEADER;
+ }
+
+ throw new IgniteInternalException(
+ INTERNAL_ERR,
+ "Failed to get a leader for the RAFT replication group [get=" + replicaGrpId + "].",
+ throwable
+ );
+ })
+ .thenCompose(leaderWithTerm -> {
+ if (leaderWithTerm.isEmpty() || !isTokenStillValidPrimary(request.enlistmentConsistencyToken())) {
+ return nullCompletedFuture();
Review Comment:
Let's log it with [DEBUG] level I guess.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1869422011
##########
modules/catalog-compaction/src/integrationTest/java/org/apache/ignite/internal/catalog/compaction/ItCatalogCompactionTest.java:
##########
@@ -51,14 +51,13 @@
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.tx.Transaction;
import org.apache.ignite.tx.TransactionOptions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Integration tests to verify catalog compaction.
*/
-class ItCatalogCompactionTest extends ClusterPerClassIntegrationTest {
+class ItCatalogCompactionTest extends ClusterPerTestIntegrationTest {
Review Comment:
`ItCatalogCompactionTest` is `ClusterPerTestIntegrationTest` now because per class version saves non-actual tables with id's. Thus we should change static methods and fields to instance methods and fields.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1876490593
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
Done
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871852162
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
My fault. By failover I mean failHandler
`failureManager.process(new FailureContext(CRITICAL_ERROR, e));`
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871192893
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1248,25 +1264,27 @@ void start(UUID localNodeId) {
}
private CompletableFuture<Boolean> onPrimaryElected(PrimaryReplicaEventParameters parameters) {
- ReplicationGroupId groupId = parameters.groupId();
- ReplicaStateContext context = getContext(groupId);
+ TablePartitionId replicationGroupId = (TablePartitionId) parameters.groupId();
Review Comment:
There's no need to convert abstract ReplicationGroupId to specific TablePartitionId. ReplicaManager should be unaware of the specific type.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1872693617
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1323,79 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(ReplicationGroupId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
Review Comment:
No, I think that `!electedPrimaryReplica.isDone()` isn't possible. Moreover even if then there is not the case.
Why the state is impossible. There are 3 places to create the future:
1. when replica starts
- if the future already was created -- complete with new replica;
- otherwise put new replica future to the `replicas` map.
2. when `ReplicaManager` got `PlacementDriver`'s message and it may be only `LeaseGrantMessage`.
3. when we got a `ReplicaRequest` for yet not started replica and then we create a future and bind a request handle on incomplete future.
Point 2 implies that we won't get any `PRIMARY_REPLICA_ELECTED` event until replica future will be completed, because then replica couldn't handle `LeaseGrantMessage`and became a primary.
And why even if it might be possible it's not the case. When we should check `isDone` on replica future?
- On `ReplicaManager` / Ignite node stopping with `ReplicaStoppingException` compeltion.
- When we need urgent replication request's response without extra waiting.
That's why I think we may wait there for (may be exceptional) completeness.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871785549
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
+ return null;
+ });
+ }
+
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void unregisterFailoverCallback(PrimaryReplicaEventParameters parameters) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(parameters.groupId());
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenAccept(expiredPrimaryReplica -> expiredPrimaryReplica.raftClient()
+ .unsubscribeLeader(onLeaderElectedFailoverCallback)
+ );
+ }
+
+ private void changePeersAndLearnersAsyncIfPendingExists(
+ Replica primaryReplica,
+ TablePartitionId replicationGroupId,
+ long term
+ ) {
+ getPendingAssignmentsSupplier.apply(replicationGroupId).exceptionally(e -> {
+ LOG.error(
+ format(
Review Comment:
Done!
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871772817
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
Review Comment:
I may be don't fully understend. In the code above `changePeersAndLearnersAsyncIfPendingExists` *is* the callback. I did it as the field because (yet) I need the lambda's object to unsubscribe.
Also this callback doesn't send the new request, just straightforward call `changePeersAndLearners` inside.
But `TableManager` do it, and yes, in worse case `changePeersAndLearners` will be called twice: from the new request sent from `TableManager` and the call from callback on leader elected.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871775738
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
Done, wonder why didn't
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1869432618
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/replication/ChangePeersAndLearnersReplicaRequest.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.partition.replicator.network.replication;
+
+import org.apache.ignite.internal.network.annotations.Transferable;
+import org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
+import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest;
+import org.apache.ignite.internal.replicator.message.ReplicaRequest;
+
+/**
+ * Request for performing {@link org.apache.ignite.internal.raft.service.RaftGroupService#changePeersAndLearnersAsync} on a primary replica.
+ */
+@Transferable(PartitionReplicationMessageGroup.CHANGE_PEERS_AND_LEARNERS_REPLICA_REQUEST)
+public interface ChangePeersAndLearnersReplicaRequest extends ReplicaRequest {
+ /** New peers configuration to rebalance. */
+ BinaryTupleMessage pendingAssignments();
Review Comment:
I bet I looked for something to serialize a linear collection (like assignments) and `BinaryTupleMessage` with `elementsCount` looked good. And I saw at, probably, something like `ScanRetrieveBatchReplicaRequest` that uses the tuple type for keys encoding.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871160914
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -319,7 +322,8 @@ public ReplicaManager(
RaftManager raftManager,
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
- Executor replicaStartStopExecutor
+ Executor replicaStartStopExecutor,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
@param declaration is also missing, please check other places two.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1869495833
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/replication/ChangePeersAndLearnersAsyncReplicaRequest.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.partition.replicator.network.replication;
+
+import org.apache.ignite.internal.network.annotations.Transferable;
+import org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
+import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest;
+
+/**
+ * Request for performing {@link org.apache.ignite.internal.raft.service.RaftGroupService#changePeersAndLearnersAsync} on a primary replica.
+ */
+@Transferable(PartitionReplicationMessageGroup.CHANGE_PEERS_AND_LEARNERS_ASYNC_REPLICA_REQUEST)
+public interface ChangePeersAndLearnersAsyncReplicaRequest extends PrimaryReplicaRequest {
+ /** New peers configuration to rebalance. */
+ BinaryTupleMessage pendingAssignments();
Review Comment:
Done with byte[]
##########
modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java:
##########
@@ -1252,8 +1254,10 @@ public CompletableFuture<Boolean> invoke(
partitionRaftConfigurer,
view -> new LocalLogStorageFactory(),
ForkJoinPool.commonPool(),
- t -> converter.get().apply(t)
- );
+ t -> converter.get().apply(t),
+ replicaGrpId -> metaStorageManager.get(ZoneRebalanceUtil.pendingPartAssignmentsKey((ZonePartitionId) replicaGrpId))
Review Comment:
Done
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871748723
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -319,7 +322,8 @@ public ReplicaManager(
RaftManager raftManager,
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
- Executor replicaStartStopExecutor
+ Executor replicaStartStopExecutor,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
Done there in `ReplicaManager` and also `TestReplicaMetaImpl` had missed `@param`s, thank you!
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871747789
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -263,7 +264,8 @@ public ReplicaManager(
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
Executor replicaStartStopExecutor,
- Function<ReplicaRequest, ReplicationGroupId> groupIdConverter
+ Function<ReplicaRequest, ReplicationGroupId> groupIdConverter,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
Done
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871865524
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1323,79 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(ReplicationGroupId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
Review Comment:
Is it possible to get !null replicaManager.replica(replicationGroupId) that won't be completed? In other words:
is `assert replicaFuture == null || replicaFuture.isDone` valid?
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1875560572
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
> Also I'm not sure: should I do retries then on L1448-1450?
Just add a todo https://issues.apache.org/jira/browse/IGNITE-23633
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1868937019
##########
modules/placement-driver-api/src/testFixtures/java/org/apache/ignite/internal/placementdriver/TestReplicaMetaImpl.java:
##########
@@ -63,14 +68,25 @@ public class TestReplicaMetaImpl implements ReplicaMeta {
* @param leaseholderId Lease holder ID, {@code null} if nothing holds the lease.
*/
public TestReplicaMetaImpl(@Nullable String leaseholder, @Nullable UUID leaseholderId) {
Review Comment:
Why leaseholderId is nullable?
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871819849
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
1. I guess yes.
2. I guess yes.
Up to you.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871159693
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -263,7 +264,8 @@ public ReplicaManager(
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
Executor replicaStartStopExecutor,
- Function<ReplicaRequest, ReplicationGroupId> groupIdConverter
+ Function<ReplicaRequest, ReplicationGroupId> groupIdConverter,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
@param declaration is missing.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871879915
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -2248,6 +2256,46 @@ private static PartitionSet extendPartitionSet(@Nullable PartitionSet oldPartiti
return newPartitionSet;
}
+ private void executeIfLocalNodeIsPrimaryForGroup(
Review Comment:
I totally missed that part. I didn't expect that you will update TableManager. Why do you need this?
We can discuss this in person if you want.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1872693617
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1323,79 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(ReplicationGroupId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
Review Comment:
No, I think that `!electedPrimaryReplica.isDone()` isn't possible. Moreover even if then there is not the case.
When we should check `isDone` on replica future?
- On `ReplicaManager` / Ignite node stopping with `ReplicaStoppingException` compeltion.
- When we need urgent replication request's response without extra waiting.
That's why I think we may wait there for (may be exceptional) completeness there.
And why the state is impossible. There are 3 places to create the future:
1. when replica starts
- if the future already was created -- complete with new replica;
- otherwise put new replica future to the `replicas` map.
2. when `ReplicaManager` got `PlacementDriver`'s message and it may be only `LeaseGrantMessage`.
3. when we got a `ReplicaRequest` for yet not started replica and then we create a future and bind a request handle on incomplete future.
Point 2 implies that we won't get any `PRIMARY_REPLICA_ELECTED` event until replica future will be completed, because then replica couldn't handle `LeaseGrantMessage`and became a primary.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc merged PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871200509
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
Here and there busy locks are missing.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871347545
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
+ return null;
+ });
+ }
+
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void unregisterFailoverCallback(PrimaryReplicaEventParameters parameters) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(parameters.groupId());
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenAccept(expiredPrimaryReplica -> expiredPrimaryReplica.raftClient()
+ .unsubscribeLeader(onLeaderElectedFailoverCallback)
+ );
+ }
+
+ private void changePeersAndLearnersAsyncIfPendingExists(
+ Replica primaryReplica,
+ TablePartitionId replicationGroupId,
+ long term
+ ) {
+ getPendingAssignmentsSupplier.apply(replicationGroupId).exceptionally(e -> {
+ LOG.error(
+ format(
Review Comment:
There's no need in using format, there's a `error(String msg, @Nullable Throwable th, Object... params)` method.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1872615791
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -2248,6 +2256,46 @@ private static PartitionSet extendPartitionSet(@Nullable PartitionSet oldPartiti
return newPartitionSet;
}
+ private void executeIfLocalNodeIsPrimaryForGroup(
Review Comment:
Yep, I mean that now it's PrimaryReplica to watch pending changes instead of TableManager. Anyway let it be as you've implemented it for now in order not to inflate the ticket.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871749627
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -319,7 +322,8 @@ public ReplicaManager(
RaftManager raftManager,
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
- Executor replicaStartStopExecutor
+ Executor replicaStartStopExecutor,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
(wonder how many notifications the user `@param` could see if the person exists)
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1868937019
##########
modules/placement-driver-api/src/testFixtures/java/org/apache/ignite/internal/placementdriver/TestReplicaMetaImpl.java:
##########
@@ -63,14 +68,25 @@ public class TestReplicaMetaImpl implements ReplicaMeta {
* @param leaseholderId Lease holder ID, {@code null} if nothing holds the lease.
*/
public TestReplicaMetaImpl(@Nullable String leaseholder, @Nullable UUID leaseholderId) {
Review Comment:
Why leaseholderId is nullable?
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1870844747
##########
modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java:
##########
@@ -305,14 +305,16 @@ private static boolean recoverable(Throwable t) {
* @return Future that is completed when all subscription messages to peers are sent.
*/
public CompletableFuture<Void> subscribeLeader(LeaderElectionListener callback) {
- assert !serverEventHandler.isSubscribed() : "The node already subscribed";
+ if (serverEventHandler.isSubscribed()) {
Review Comment:
Done
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871816660
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -319,7 +322,8 @@ public ReplicaManager(
RaftManager raftManager,
RaftGroupOptionsConfigurer partitionRaftConfigurer,
LogStorageFactoryCreator volatileLogStorageFactoryCreator,
- Executor replicaStartStopExecutor
+ Executor replicaStartStopExecutor,
+ Function<ReplicationGroupId, CompletableFuture<byte[]>> getPendingAssignmentsSupplier
Review Comment:
> Param is a Sanskrit word that means "the best" or "the highest." It is a unisex name, but it is more commonly given to boys. The name is often used in the context of yoga and spirituality, as it refers to the Supreme Being or the Divine.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871132777
##########
modules/placement-driver-api/src/testFixtures/java/org/apache/ignite/internal/placementdriver/TestPlacementDriver.java:
##########
@@ -112,8 +112,29 @@ public Supplier<? extends ReplicaMeta> getPrimaryReplicaSupplier() {
return this.primaryReplicaSupplier;
}
- public void setPrimaryReplicaSupplier(Supplier<? extends ReplicaMeta> primaryReplicaSupplier) {
+ /**
+ * Setter for a test primary replica supplier with {@code PRIMARY_REPLICA_ELECTED} event firing that is crucial for some tests internal
+ * logic that depends on the event handling.
+ *
+ * @param primaryReplicaSupplier The supplier that provides {@link TestReplicaMetaImpl} instance with a test primary replica meta
+ * information.
+ */
+ public void setPrimaryReplicaSupplier(Supplier<? extends TestReplicaMetaImpl> primaryReplicaSupplier) {
this.primaryReplicaSupplier = primaryReplicaSupplier;
+
+ TestReplicaMetaImpl replicaMeta = primaryReplicaSupplier.get();
+
+ fireEvent(
+ PrimaryReplicaEvent.PRIMARY_REPLICA_ELECTED,
+ new PrimaryReplicaEventParameters(
+ 0,
Review Comment:
Makes sense.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871335037
##########
modules/catalog-compaction/src/integrationTest/java/org/apache/ignite/internal/catalog/compaction/ItCatalogCompactionTest.java:
##########
@@ -51,14 +51,13 @@
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.tx.Transaction;
import org.apache.ignite.tx.TransactionOptions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Integration tests to verify catalog compaction.
*/
-class ItCatalogCompactionTest extends ClusterPerClassIntegrationTest {
+class ItCatalogCompactionTest extends ClusterPerTestIntegrationTest {
Review Comment:
Due to personal discussion there was found that the drastic reason relates to [IGNITE-23753](https://issues.apache.org/jira/browse/IGNITE-23753).
If we'll add replica state on assertion at the revision `1fe7f5ff` we could see then `ASSIGNED` state for already removed replicas. The problem is similar to [IGNITE-23753](https://issues.apache.org/jira/browse/IGNITE-23753), but reason differ: we have 2 places in `TableManager` where `stopReplica` raw calls are done:
1. [IGNITE-23753](https://issues.apache.org/jira/browse/IGNITE-23753)'s issue on Ignite node stopping process;
2. on drop table process: `onLwmChanged` -> `destroyTableLocally` -> `stopAndDestroyPartition` -> `stopPartition` -> `stopReplica`.
In both cases we call `stopReplica` instead `weakStopReplica` with a particular reason and replica's states handling. It leads to wrong states and possible memory leak because `ASSIGNED` states shouldn't be deleted.
The issue should be investigated in [IGNITE-23753](https://issues.apache.org/jira/browse/IGNITE-23753), for now test class after 20 repeated runs is green locally due to no-op handling on null-value replica future. But bug with states is confirmed.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1870797812
##########
modules/placement-driver-api/src/testFixtures/java/org/apache/ignite/internal/placementdriver/TestPlacementDriver.java:
##########
@@ -112,8 +112,29 @@ public Supplier<? extends ReplicaMeta> getPrimaryReplicaSupplier() {
return this.primaryReplicaSupplier;
}
- public void setPrimaryReplicaSupplier(Supplier<? extends ReplicaMeta> primaryReplicaSupplier) {
+ /**
+ * Setter for a test primary replica supplier with {@code PRIMARY_REPLICA_ELECTED} event firing that is crucial for some tests internal
+ * logic that depends on the event handling.
+ *
+ * @param primaryReplicaSupplier The supplier that provides {@link TestReplicaMetaImpl} instance with a test primary replica meta
+ * information.
+ */
+ public void setPrimaryReplicaSupplier(Supplier<? extends TestReplicaMetaImpl> primaryReplicaSupplier) {
this.primaryReplicaSupplier = primaryReplicaSupplier;
+
+ TestReplicaMetaImpl replicaMeta = primaryReplicaSupplier.get();
+
+ fireEvent(
+ PrimaryReplicaEvent.PRIMARY_REPLICA_ELECTED,
+ new PrimaryReplicaEventParameters(
+ 0,
Review Comment:
TLDR: yes, but tricky.
The event is local and if we look at usages, then the only usage of `causalityToken()` from the parameters is `IndexBuildController` that doesn't use in tests. So, we may assume that 0 is safe. I add the corresponding commentary before 0.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871754008
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1248,25 +1264,27 @@ void start(UUID localNodeId) {
}
private CompletableFuture<Boolean> onPrimaryElected(PrimaryReplicaEventParameters parameters) {
- ReplicationGroupId groupId = parameters.groupId();
- ReplicaStateContext context = getContext(groupId);
+ TablePartitionId replicationGroupId = (TablePartitionId) parameters.groupId();
Review Comment:
Done. Don't remember why I cast 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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871789704
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
I bet no, because the exception means one of:
1. we couldn't subscribe our client and then won't get new events with terms;
2. we couldn't get a leader, so we can't perform anything with failover then.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1873042497
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
Did with local `ReplicaStateManager#busyLock`, but I wish that I do it right
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1873043098
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1323,79 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(ReplicationGroupId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
Review Comment:
Assertions are added
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871879915
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -2248,6 +2256,46 @@ private static PartitionSet extendPartitionSet(@Nullable PartitionSet oldPartiti
return newPartitionSet;
}
+ private void executeIfLocalNodeIsPrimaryForGroup(
Review Comment:
I totally missed that part. I didn't expect that you will update TableManager. Why do you need 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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1872693617
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1323,79 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(ReplicationGroupId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
Review Comment:
No, I think that `!electedPrimaryReplica.isDone()` isn't possible. Moreover even if then there is not the case.
When we should check `isDone` on replica future?
- On `ReplicaManager` / Ignite node stopping with `ReplicaStoppingException` compeltion.
- When we need urgent replication request's response without extra waiting.
That's why I think we may wait there for (may be exceptional) completeness.
And why the state is impossible. There are 3 places to create the future:
1. when replica starts
- if the future already was created -- complete with new replica;
- otherwise put new replica future to the `replicas` map.
2. when `ReplicaManager` got `PlacementDriver`'s message and it may be only `LeaseGrantMessage`.
3. when we got a `ReplicaRequest` for yet not started replica and then we create a future and bind a request handle on incomplete future.
Point 2 implies that we won't get any `PRIMARY_REPLICA_ELECTED` event until replica future will be completed, because then replica couldn't handle `LeaseGrantMessage`and became a primary.
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "JAkutenshi (via GitHub)" <gi...@apache.org>.
JAkutenshi commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1869494932
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/replication/ChangePeersAndLearnersReplicaRequest.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.partition.replicator.network.replication;
+
+import org.apache.ignite.internal.network.annotations.Transferable;
+import org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
+import org.apache.ignite.internal.replicator.message.PrimaryReplicaRequest;
+import org.apache.ignite.internal.replicator.message.ReplicaRequest;
+
+/**
+ * Request for performing {@link org.apache.ignite.internal.raft.service.RaftGroupService#changePeersAndLearnersAsync} on a primary replica.
+ */
+@Transferable(PartitionReplicationMessageGroup.CHANGE_PEERS_AND_LEARNERS_REPLICA_REQUEST)
+public interface ChangePeersAndLearnersReplicaRequest extends ReplicaRequest {
+ /** New peers configuration to rebalance. */
+ BinaryTupleMessage pendingAssignments();
Review Comment:
But as mentioned below I change it to `byte[]`
--
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-22036 Replace TableManager.changePeersOnRebalance by the broadcast ReplicaRequest [ignite-3]
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #4446:
URL: https://github.com/apache/ignite-3/pull/4446#discussion_r1871246642
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
Review Comment:
thenCompose in order to flat futures, WDYT?
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
Review Comment:
Am I right that it worst case we will send changePeersAndLearners twice: on changePeersAndLearnersAsyncIfPendingExists and onLeaderElectedFailoverCallback?
##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -1298,6 +1319,93 @@ private CompletableFuture<Boolean> onPrimaryExpired(PrimaryReplicaEventParameter
return falseCompletedFuture();
}
+ // TODO: move to Replica https://issues.apache.org/jira/browse/IGNITE-23750
+ private void registerFailoverCallback(TablePartitionId replicationGroupId) {
+ CompletableFuture<Replica> replicaFuture = replicaManager.replica(replicationGroupId);
+
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-23753
+ // For now we assume that it's a possible situation to get null future on node's stopp process, but it should be fixed with
+ // a correct and consistent replica's state.
+ if (replicaFuture == null) {
+ return;
+ }
+
+ replicaFuture.thenApply(electedPrimaryReplica -> {
+ onLeaderElectedFailoverCallback = (leaderNode, term) -> changePeersAndLearnersAsyncIfPendingExists(
+ electedPrimaryReplica,
+ replicationGroupId,
+ term
+ );
+
+ return electedPrimaryReplica.raftClient().subscribeLeader(onLeaderElectedFailoverCallback);
+ }).exceptionally(e -> {
+ LOG.error("Rebalance failover subscription on elected primary replica failed [groupId=" + replicationGroupId + "].", e);
+
Review Comment:
Should we trigger failHandler in that case?
--
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