Skip to content

Commit 3201ca4

Browse files
authored
HDDS-12952. Make OmSnapshotManager#snapshotLimitCheck thread-safe and consistent (apache#8381)
1 parent 522c88d commit 3201ca4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,16 @@ private void validateSnapshotsExistAndActive(final String volumeName,
872872
public void snapshotLimitCheck() throws IOException, OMException {
873873
OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl) ozoneManager.getMetadataManager();
874874
SnapshotChainManager snapshotChainManager = omMetadataManager.getSnapshotChainManager();
875-
int currentSnapshotNum = snapshotChainManager.getGlobalSnapshotChain().size();
876875

877-
AtomicReference<OMException> exceptionRef = new AtomicReference<>(null);
876+
AtomicReference<IOException> exceptionRef = new AtomicReference<>(null);
878877
inFlightSnapshotCount.updateAndGet(count -> {
878+
int currentSnapshotNum = 0;
879+
try {
880+
currentSnapshotNum = snapshotChainManager.getGlobalSnapshotChain().size();
881+
} catch (IOException e) {
882+
exceptionRef.set(e);
883+
return count;
884+
}
879885
if (currentSnapshotNum + count >= fsSnapshotMaxLimit) {
880886
exceptionRef.set(new OMException(
881887
String.format("Snapshot limit of %d reached. Cannot create more snapshots. " +

0 commit comments

Comments
 (0)