You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "siddhantsangwan (via GitHub)" <gi...@apache.org> on 2025/02/25 07:32:02 UTC

[PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

siddhantsangwan opened a new pull request, #7964:
URL: https://github.com/apache/ozone/pull/7964

   ## What changes were proposed in this pull request?
   
   There have been situations where a replica reports with higher BCSID than SCM knows for a container that is already CLOSED. This ideally should not happen, but can happen because of bugs in the Datanode side applyTransaction and ratis group removal path.
   
   Currently, when handling a container report in SCM:
   ```
       if (isHealthy(replicaProto::getState)) {
         if (containerInfo.getSequenceId() <
             replicaProto.getBlockCommitSequenceId()) {
           containerInfo.updateSequenceId(
               replicaProto.getBlockCommitSequenceId());
         }
   ```
   we check if the replica is healthy and if the container's sequence is lower than the replica's. We then update the sequence id:
   ```
     public void updateSequenceId(long sequenceID) {
       assert (isOpen() || state == HddsProtos.LifeCycleState.QUASI_CLOSED);
       sequenceId = max(sequenceID, sequenceId);
     }
   ```
   
   There's an assert statement there because we don't expect to update a CLOSED container's sequence id, but if the code is built without `-enableassertions`, this will not fail.
   
   I propose to log an error message here to make this situation visible in the logs. We need further discussion on whether updating the sequence id of a CLOSED container should be allowed at all by default - should we crash the SCM and allow it only once an admin has reviewed the situation and explicitly set a configuration that this update should be allowed? **This jira is restricted to logging**, a separate jira should be created to change the default behaviour.
   
   ## What is the link to the Apache JIRA
   
   http://issues.apache.org/jira/browse/HDDS-12409
   
   ## How was this patch tested?
   
   Manual testing. Here is what the log would look like:
   ```
   2025-02-25 12:54:18,664 [main] ERROR container.ContainerReportHandler (AbstractContainerReportHandler.java:updateContainerStats(137)) - There is a CLOSED container with lower sequence ID than a replica. Container: ContainerInfo{id=#1, state=CLOSED, stateEnterTime=2025-02-25T07:24:18.523Z, pipelineID=PipelineID=b7e9594b-a121-43fb-b416-561903af525d, owner=scm}, Container's sequence ID: 100, Replica: containerID: 1
   state: OPEN
   keyCount: 101
   blockCommitSequenceId: 101
   originNodeId: "49dcc98b-f44d-4adc-b973-879044d1ab65"
   isEmpty: true
   , Replica's sequence ID: 101, Datanode: 49dcc98b-f44d-4adc-b973-879044d1ab65(localhost-2.3.5.5/2.3.5.5).
   
   ```


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 commented on PR #7964:
URL: https://github.com/apache/ozone/pull/7964#issuecomment-2705819772

   @adoroszlai, the review comment is addressed. Can you take another look at 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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 merged PR #7964:
URL: https://github.com/apache/ozone/pull/7964


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 commented on code in PR #7964:
URL: https://github.com/apache/ozone/pull/7964#discussion_r1971961480


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/AbstractContainerReportHandler.java:
##########
@@ -132,6 +132,13 @@ private void updateContainerStats(final DatanodeDetails datanodeDetails,
                                     final ContainerInfo containerInfo,
                                     final ContainerReplicaProto replicaProto)
       throws ContainerNotFoundException {
+    if (containerInfo.getState() == HddsProtos.LifeCycleState.CLOSED && containerInfo.getSequenceId() <
+        replicaProto.getBlockCommitSequenceId()) {
+      logger.error(
+          "There is a CLOSED container with lower sequence ID than a replica. Container: {}, Container's " +
+              "sequence ID: {}, Replica: {}, Replica's sequence ID: {}, Datanode: {}.", containerInfo,
+          containerInfo.getSequenceId(), replicaProto, replicaProto.getBlockCommitSequenceId(), datanodeDetails);

Review Comment:
   +1 for flattening the output in the log.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7964:
URL: https://github.com/apache/ozone/pull/7964#discussion_r1970485656


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/AbstractContainerReportHandler.java:
##########
@@ -132,6 +132,13 @@ private void updateContainerStats(final DatanodeDetails datanodeDetails,
                                     final ContainerInfo containerInfo,
                                     final ContainerReplicaProto replicaProto)
       throws ContainerNotFoundException {
+    if (containerInfo.getState() == HddsProtos.LifeCycleState.CLOSED && containerInfo.getSequenceId() <
+        replicaProto.getBlockCommitSequenceId()) {
+      logger.error(
+          "There is a CLOSED container with lower sequence ID than a replica. Container: {}, Container's " +
+              "sequence ID: {}, Replica: {}, Replica's sequence ID: {}, Datanode: {}.", containerInfo,
+          containerInfo.getSequenceId(), replicaProto, replicaProto.getBlockCommitSequenceId(), datanodeDetails);

Review Comment:
   Protobuf message (`replicaProto`) is converted to string using newline as separator.  I think that looks odd in the log:
   
   ```
   Replica: containerID: 1
   state: OPEN
   keyCount: 101
   blockCommitSequenceId: 101
   originNodeId: "49dcc98b-f44d-4adc-b973-879044d1ab65"
   isEmpty: true
   ,
   ```
   
   Should we convert single line, something like for audit log?
   
   https://github.com/apache/ozone/blob/052bd2deef51e79090e3f61ca47ec82eedf85e6f/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java#L311
   
   https://github.com/apache/ozone/blob/052bd2deef51e79090e3f61ca47ec82eedf85e6f/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java#L483-L488



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12409. Log an error before increasing the sequence id of a CLOSED container in SCM [ozone]

Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 commented on PR #7964:
URL: https://github.com/apache/ozone/pull/7964#issuecomment-2705950893

   Thanks @siddhantsangwan for the contribution and @sodonnel @adoroszlai  for the review.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org