You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "rpuch (via GitHub)" <gi...@apache.org> on 2023/09/25 14:48:16 UTC

[GitHub] [ignite-3] rpuch opened a new pull request, #2628: IGNITE-20410 ItSchemaSyncAndReplicationTest#laggingSchemasPreventPartitionDataReplication fails with ReplicationTimeoutException

rpuch opened a new pull request, #2628:
URL: https://github.com/apache/ignite-3/pull/2628

   https://issues.apache.org/jira/browse/IGNITE-20410
   
   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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628#discussion_r1336677690


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java:
##########
@@ -1645,6 +1640,23 @@ private void executeApplyingTasks(final List<LogEntryAndClosure> tasks) {
         }
     }
 
+    /**
+     * Builds a status for 'Cannot apply because this node is not a leader' situation.
+     *
+     * @param nodeState Node state.
+     */
+    public static Status cannotApplyBecauseNotLeaderStatus(State nodeState) {

Review Comment:
   There's nothing about "cannot apply" in the status itself. Why did you chose such a specific name?



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java:
##########
@@ -59,20 +72,53 @@ public CheckCatalogVersionOnActionRequest(CatalogService catalogService) {
             if (!isMetadataAvailableFor(requiredCatalogVersion, catalogService)) {
                 // TODO: IGNITE-20298 - throttle logging.
                 LOG.warn(
-                        "Metadata not yet available, group {}, required level {}; rejecting ActionRequest with EBUSY.",
+                        "Metadata not yet available, rejecting ActionRequest with EBUSY [group={}, requiredLevel={}].",
                         request.groupId(), requiredCatalogVersion
                 );
 
                 return RaftRpcFactory.DEFAULT //
                     .newResponse(
                             node.getRaftOptions().getRaftMessagesFactory(),
                             RaftError.EBUSY,
-                            "Metadata not yet available, group '%s', required level %d; rejecting ActionRequest with EBUSY.",
+                            "Metadata not yet available, rejecting ActionRequest with EBUSY [group=%s, requiredLevel=%d].",
                             request.groupId(), requiredCatalogVersion
                     );
             }
         }
 
         return null;
     }
+
+    /**
+     * Builds an {@link org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse} if the current node is not a leader.
+     * It tries to mirror the behavior of {@link NodeImpl} in this regard.
+     *
+     * <p>NB that it's important to return leaderId for the 'not a leader and not transferring leadership' state
+     * so that the caller switches to the actual leader.
+     *
+     * @param node The node.
+     * @return ErrorResponse if this node is not a leader, {@code null} otherwise.
+     */
+    private static @Nullable Message errorResponseIfNotLeader(Node node) {
+        State state = node.getNodeState();
+
+        if (state == State.STATE_LEADER) {
+            return null;
+        }
+
+        Status st = NodeImpl.cannotApplyBecauseNotLeaderStatus(state);
+
+        PeerId leaderId = node.getLeaderId();
+
+        if (st.getRaftError() == RaftError.EPERM && leaderId != null) {

Review Comment:
   What does this mean? Please leave a comment that it's "not a leader" status.
   By the way, why is it necessary to check the code? Is it not enough to have a leaderId check?
   Last question, why do we create responses differently in these cases?



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


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628#discussion_r1336703148


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java:
##########
@@ -59,20 +72,53 @@ public CheckCatalogVersionOnActionRequest(CatalogService catalogService) {
             if (!isMetadataAvailableFor(requiredCatalogVersion, catalogService)) {
                 // TODO: IGNITE-20298 - throttle logging.
                 LOG.warn(
-                        "Metadata not yet available, group {}, required level {}; rejecting ActionRequest with EBUSY.",
+                        "Metadata not yet available, rejecting ActionRequest with EBUSY [group={}, requiredLevel={}].",
                         request.groupId(), requiredCatalogVersion
                 );
 
                 return RaftRpcFactory.DEFAULT //
                     .newResponse(
                             node.getRaftOptions().getRaftMessagesFactory(),
                             RaftError.EBUSY,
-                            "Metadata not yet available, group '%s', required level %d; rejecting ActionRequest with EBUSY.",
+                            "Metadata not yet available, rejecting ActionRequest with EBUSY [group=%s, requiredLevel=%d].",
                             request.groupId(), requiredCatalogVersion
                     );
             }
         }
 
         return null;
     }
+
+    /**
+     * Builds an {@link org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse} if the current node is not a leader.
+     * It tries to mirror the behavior of {@link NodeImpl} in this regard.
+     *
+     * <p>NB that it's important to return leaderId for the 'not a leader and not transferring leadership' state
+     * so that the caller switches to the actual leader.
+     *
+     * @param node The node.
+     * @return ErrorResponse if this node is not a leader, {@code null} otherwise.
+     */
+    private static @Nullable Message errorResponseIfNotLeader(Node node) {
+        State state = node.getNodeState();
+
+        if (state == State.STATE_LEADER) {
+            return null;
+        }
+
+        Status st = NodeImpl.cannotApplyBecauseNotLeaderStatus(state);
+
+        PeerId leaderId = node.getLeaderId();
+
+        if (st.getRaftError() == RaftError.EPERM && leaderId != null) {

Review Comment:
   I added a comment and simplified the code.
   
   As for 'why don't just return leaderId if we have it', take a look at `IgniteCliRpcRequestClosure:74`: they only enrich the response with leaderId for EPERM. I did not want to change this to avoid breaking this protocol.



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


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628#discussion_r1336686016


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java:
##########
@@ -1645,6 +1640,23 @@ private void executeApplyingTasks(final List<LogEntryAndClosure> tasks) {
         }
     }
 
+    /**
+     * Builds a status for 'Cannot apply because this node is not a leader' situation.
+     *
+     * @param nodeState Node state.
+     */
+    public static Status cannotApplyBecauseNotLeaderStatus(State nodeState) {

Review Comment:
   Because this method checks for this specific situation. When it finds out that 'it cannot apply because not a leader', it returns this status.



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


[GitHub] [ignite-3] ibessonov merged pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628


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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628#discussion_r1336710624


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java:
##########
@@ -59,20 +72,53 @@ public CheckCatalogVersionOnActionRequest(CatalogService catalogService) {
             if (!isMetadataAvailableFor(requiredCatalogVersion, catalogService)) {
                 // TODO: IGNITE-20298 - throttle logging.
                 LOG.warn(
-                        "Metadata not yet available, group {}, required level {}; rejecting ActionRequest with EBUSY.",
+                        "Metadata not yet available, rejecting ActionRequest with EBUSY [group={}, requiredLevel={}].",
                         request.groupId(), requiredCatalogVersion
                 );
 
                 return RaftRpcFactory.DEFAULT //
                     .newResponse(
                             node.getRaftOptions().getRaftMessagesFactory(),
                             RaftError.EBUSY,
-                            "Metadata not yet available, group '%s', required level %d; rejecting ActionRequest with EBUSY.",
+                            "Metadata not yet available, rejecting ActionRequest with EBUSY [group=%s, requiredLevel=%d].",
                             request.groupId(), requiredCatalogVersion
                     );
             }
         }
 
         return null;
     }
+
+    /**
+     * Builds an {@link org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse} if the current node is not a leader.
+     * It tries to mirror the behavior of {@link NodeImpl} in this regard.
+     *
+     * <p>NB that it's important to return leaderId for the 'not a leader and not transferring leadership' state
+     * so that the caller switches to the actual leader.
+     *
+     * @param node The node.
+     * @return ErrorResponse if this node is not a leader, {@code null} otherwise.
+     */
+    private static @Nullable Message errorResponseIfNotLeader(Node node) {
+        State state = node.getNodeState();
+
+        if (state == State.STATE_LEADER) {
+            return null;
+        }
+
+        Status st = NodeImpl.cannotApplyBecauseNotLeaderStatus(state);
+
+        PeerId leaderId = node.getLeaderId();
+
+        if (st.getRaftError() == RaftError.EPERM && leaderId != null) {

Review Comment:
   That's crazy, thank you for the explanation



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


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2628: IGNITE-20410 CheckCatalogVersionOnActionRequest breaks RAFT client leaderId refresh protocol

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2628:
URL: https://github.com/apache/ignite-3/pull/2628#discussion_r1336710206


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java:
##########
@@ -1645,6 +1640,23 @@ private void executeApplyingTasks(final List<LogEntryAndClosure> tasks) {
         }
     }
 
+    /**
+     * Builds a status for 'Cannot apply because this node is not a leader' situation.
+     *
+     * @param nodeState Node state.
+     */
+    public static Status cannotApplyBecauseNotLeaderStatus(State nodeState) {

Review Comment:
   From what I see, method knows nothing about "cannot apply", it only converts one status to another, that's why I asked the question. But I see what you mean



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