diff --git a/ambry-router/src/main/java/com/github/ambry/router/UndeleteOperation.java b/ambry-router/src/main/java/com/github/ambry/router/UndeleteOperation.java index a6a1bba139..fffdb81587 100644 --- a/ambry-router/src/main/java/com/github/ambry/router/UndeleteOperation.java +++ b/ambry-router/src/main/java/com/github/ambry/router/UndeleteOperation.java @@ -364,6 +364,8 @@ private RouterErrorCode processServerError(ServerErrorCode serverErrorCode) { return RouterErrorCode.BlobNotDeleted; case BlobAlreadyUndeleted: return RouterErrorCode.BlobUndeleted; + case BlobDeletedPermanently: + return RouterErrorCode.BlobDeleted; case BlobLifeVersionConflict: return RouterErrorCode.LifeVersionConflict; default: diff --git a/ambry-router/src/test/java/com/github/ambry/router/UndeleteManagerTest.java b/ambry-router/src/test/java/com/github/ambry/router/UndeleteManagerTest.java index caa001cc96..a31d3c3383 100644 --- a/ambry-router/src/test/java/com/github/ambry/router/UndeleteManagerTest.java +++ b/ambry-router/src/test/java/com/github/ambry/router/UndeleteManagerTest.java @@ -292,6 +292,30 @@ public void singleFailureTest() throws Exception { } } + /** + * Failure tests when servers return BlobDeletedPermanently because the blob has been compacted. + * The router should surface this as RouterErrorCode.BlobDeleted. + * @throws Exception + */ + @Test + public void blobDeletedPermanentlyTest() throws Exception { + HashMap> dcToMockServers = new HashMap<>(); + serverLayout.getMockServers() + .forEach(server -> dcToMockServers.computeIfAbsent(server.getDataCenter(), k -> new ArrayList()).add(server)); + String dc = new ArrayList<>(dcToMockServers.keySet()).get(0); + List servers = dcToMockServers.get(dc); + for (String blobId : blobIds) { + deleteBlobInAllServer(blobId); + + for (MockServer server : servers.subList(0, 2)) { + server.setServerErrorForAllRequests(ServerErrorCode.BlobDeletedPermanently); + } + + executeOpAndVerify(Collections.singleton(blobId), RouterErrorCode.BlobDeleted); + serverLayout.getMockServers().forEach(server -> server.resetServerErrors()); + } + } + /** * Failure tests when undelete request is rejected due to quota compliance. * @throws Exception