This is an automated email from the ASF dual-hosted git repository.
chihsuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 62102d510a6 HDDS-16691. Surface retriable snapshot load TIMEOUT as
OMException (#11552)
62102d510a6 is described below
commit 62102d510a6b4d23b933b7eeb86ca8691f5767aa
Author: rjgoyln <[email protected]>
AuthorDate: Sat Oct 17 14:02:28 2026 +0800
HDDS-16691. Surface retriable snapshot load TIMEOUT as OMException (#11552)
---
.../apache/hadoop/ozone/om/snapshot/SnapshotCache.java | 10 +++++++++-
.../hadoop/ozone/om/snapshot/TestSnapshotCache.java | 15 +++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
index 40a92b1ae0e..1c7e63159f4 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
@@ -219,6 +219,10 @@ public UncheckedAutoCloseableSupplier<OmSnapshot> get(UUID
key) throws IOExcepti
throw new OMException("Unable to acquire readlock on snapshot db with
key " + key,
OMException.ResultCodes.INTERNAL_ERROR);
}
+ // The dbMap.compute lambda cannot throw a checked exception, so a typed
load failure is parked here and
+ // rethrown below. Flattening it into an IllegalStateException loses the
result code, and callers cannot
+ // map that back to a retriable condition such as TIMEOUT.
+ AtomicReference<OMException> loadFailure = new AtomicReference<>();
try {
// Atomic operation to initialize the OmSnapshot instance (once) if the
key
// does not exist, and increment the reference count on the instance.
@@ -231,7 +235,7 @@ public UncheckedAutoCloseableSupplier<OmSnapshot> get(UUID
key) throws IOExcepti
} catch (OMException omEx) {
// Return null if the snapshot is no longer active
if
(!omEx.getResult().equals(OMException.ResultCodes.FILE_NOT_FOUND)) {
- throw new IllegalStateException(omEx);
+ loadFailure.set(omEx);
}
} catch (IOException ioEx) {
// Failed to load snapshot DB
@@ -247,6 +251,10 @@ public UncheckedAutoCloseableSupplier<OmSnapshot> get(UUID
key) throws IOExcepti
}
return v;
});
+ OMException loadException = loadFailure.get();
+ if (loadException != null) {
+ throw loadException;
+ }
if (rcOmSnapshot == null) {
throw new OMException("SnapshotId: '" + key + "' not found, or the
snapshot is no longer active.",
OMException.ResultCodes.FILE_NOT_FOUND);
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotCache.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotCache.java
index 756b60f2f39..ff729df43bc 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotCache.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotCache.java
@@ -649,6 +649,21 @@ void testCloseFailureRetriesSnapshot() throws Exception {
assertEquals(0, omMetrics.getNumSnapshotCacheSize());
}
+ @Test
+ @DisplayName("get() surfaces a retriable load TIMEOUT as OMException, not
IllegalStateException")
+ void testGetPropagatesLoadTimeout() throws Exception {
+ clearInvocations(lock);
+ final UUID snapshotId = UUID.randomUUID();
+ when(cacheLoader.load(eq(snapshotId)))
+ .thenThrow(new OMException("snapshot has not been flushed yet",
OMException.ResultCodes.TIMEOUT));
+
+ final OMException thrown = assertThrows(OMException.class, () ->
snapshotCache.get(snapshotId));
+ assertEquals(OMException.ResultCodes.TIMEOUT, thrown.getResult());
+ assertFalse(snapshotCache.getDbMap().containsKey(snapshotId));
+ verify(lock, times(1)).acquireReadLock(eq(SNAPSHOT_DB_LOCK),
eq(snapshotId.toString()));
+ verify(lock, times(1)).releaseReadLock(eq(SNAPSHOT_DB_LOCK),
eq(snapshotId.toString()));
+ }
+
@Test
@DisplayName("lock supplier releases write lock if cleanup throws an
exception")
void testLockSupplierReleasesWriteLockOnCleanupException() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]