Re: [PR] HDDS-13357. Fix OmSnapshotManager#inFlightSnapshotCount reset logic [ozone]

2026-06-10 Thread via GitHub


github-actions[bot] closed pull request #10218: HDDS-13357. Fix 
OmSnapshotManager#inFlightSnapshotCount reset logic
URL: https://github.com/apache/ozone/pull/10218


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-13357. Fix OmSnapshotManager#inFlightSnapshotCount reset logic [ozone]

2026-06-10 Thread via GitHub


github-actions[bot] commented on PR #10218:
URL: https://github.com/apache/ozone/pull/10218#issuecomment-4676035221

   Thank you for your contribution. This PR is being closed due to inactivity. 
Please contact a maintainer if you would like to reopen 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-13357. Fix OmSnapshotManager#inFlightSnapshotCount reset logic [ozone]

2026-06-02 Thread via GitHub


github-actions[bot] commented on PR #10218:
URL: https://github.com/apache/ozone/pull/10218#issuecomment-4608092046

   This PR has been marked as stale due to 21 days of inactivity. Please 
comment or remove the stale label to keep it open. Otherwise, it will be 
automatically closed in 7 days.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-13357. Fix OmSnapshotManager#inFlightSnapshotCount reset logic [ozone]

2026-05-11 Thread via GitHub


Copilot commented on code in PR #10218:
URL: https://github.com/apache/ozone/pull/10218#discussion_r3223643774


##
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java:
##
@@ -130,7 +130,12 @@ public OMRequest preExecute(OzoneManager ozoneManager) 
throws IOException {
 .setCreationTime(Time.now());
 return 
omRequest.toBuilder().setCreateSnapshotRequest(createSnapshotRequest.build()).build();
   }
-  
+
+  @Override
+  public void handleRequestFailure(OzoneManager ozoneManager) {
+ozoneManager.getOmSnapshotManager().decrementInFlightSnapshotCount();

Review Comment:
   This introduces new failure-path behavior affecting snapshot-limit 
enforcement (decrementing the in-flight counter). Please add a unit/integration 
test that exercises a post-`preExecute()` failure path (eg, PrepareState 
rejection) and asserts the in-flight counter is decremented to prevent 
unbounded growth.
   



##
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##
@@ -962,42 +962,45 @@ private void validateSnapshotsExistAndActive(final String 
volumeName,
 checkSnapshotActive(toSnapInfo, false);
   }
 
+  /**
+   * Checks snapshot limit considering in-flight count and increments the 
counter if allowed.
+   * Called in preExecute() to track and limit concurrent snapshot creations.
+   *
+   * @throws IOException if failed to get snapshot count
+   * @throws OMException if the snapshot limit would be exceeded
+   */
   public void snapshotLimitCheck() throws IOException, OMException {
 OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl) 
ozoneManager.getMetadataManager();
 SnapshotChainManager snapshotChainManager = 
omMetadataManager.getSnapshotChainManager();
 
-AtomicReference exceptionRef = new AtomicReference<>(null);
+AtomicReference exceptionRef = new AtomicReference<>(null);
 inFlightSnapshotCount.updateAndGet(count -> {
-  int currentSnapshotNum = 0;
+  int currentSnapshotCount;
   try {
-currentSnapshotNum = 
snapshotChainManager.getGlobalSnapshotChain().size();
+currentSnapshotCount = 
snapshotChainManager.getGlobalSnapshotChain().size();
+throwIfSnapshotLimitExceeded(currentSnapshotCount, count);
   } catch (IOException e) {
 exceptionRef.set(e);
 return count;
   }
-  if (currentSnapshotNum + count >= fsSnapshotMaxLimit) {
-exceptionRef.set(new OMException(
-String.format("Snapshot limit of %d reached. Cannot create more 
snapshots. " +
-"Current snapshots: %d, In-flight creations: %d",
-fsSnapshotMaxLimit, currentSnapshotNum, count) +
-" If you already deleted some snapshots, " +
-"please wait for the background service to complete the 
cleanup.",
-OMException.ResultCodes.TOO_MANY_SNAPSHOTS));
-return count;
-  }
   return count + 1;
 });
 if (exceptionRef.get() != null) {
-  throw exceptionRef.get();
+  Exception e = exceptionRef.get();
+  if (e instanceof OMException) {
+throw (OMException) e;
+  }
+  throw (IOException) e;
 }

Review Comment:
   `exceptionRef` is widened to `Exception`, but this code only ever stores 
`IOException` (including `OMException`, which is already an `IOException`). 
This adds avoidable casts and a future risk of `ClassCastException` if a 
non-`IOException` is ever stored. Prefer `AtomicReference` and 
directly `throw exceptionRef.get();` (no `instanceof`/casts needed).



##
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java:
##
@@ -168,6 +173,8 @@ public OMClientResponse validateAndUpdateCache(OzoneManager 
ozoneManager, Execut
 throw new OMException("Snapshot already exists", FILE_ALREADY_EXISTS);
   }
 
+  ozoneManager.getOmSnapshotManager().assertSnapshotLimitNotExceeded();

Review Comment:
   This adds a new hard safety-net check that can reject requests during 
`validateAndUpdateCache()`. Add a test that sets the snapshot count to 
`fsSnapshotMaxLimit` (or mocks the chain size) and validates that snapshot 
creation fails at this point with `TOO_MANY_SNAPSHOTS`, ensuring the safety net 
works independently of in-flight tracking.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-13357. Fix OmSnapshotManager#inFlightSnapshotCount reset logic [ozone]

2026-05-08 Thread via GitHub


YutaLin commented on PR #10218:
URL: https://github.com/apache/ozone/pull/10218#issuecomment-4411515699

   > @YutaLin I’d actually suggest not fixing this. The underlying problem is 
that if a follower has an incomplete snapshot create request, it’s impossible 
to fully prevent its in-flight snapshot counter from going below 0. Because of 
that, we need to keep the “don’t decrease if the in-flight count goes below 0” 
workaround.
   
   HI @peterxcli, thanks for review!
   I know it’s impossible to fully fix the reset logic because it’s an 
in-flight snapshot counter, but we can still improve the snapshot check logic 
to make it more robust. This is noted in the PR description


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]