[
https://issues.apache.org/jira/browse/HADOOP-19450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930079#comment-17930079
]
ASF GitHub Bot commented on HADOOP-19450:
-----------------------------------------
bhattmanish98 commented on code in PR #7364:
URL: https://github.com/apache/hadoop/pull/7364#discussion_r1969080817
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemRename.java:
##########
@@ -1766,4 +1745,69 @@ public void getClientTransactionIdAfterRename() throws
Exception {
.isEqualTo(clientTransactionId[0]);
}
}
+
+ @Test
+ public void failureInGetPathStatusDuringRenameRecovery() throws Exception {
+ try (AzureBlobFileSystem fs = getFileSystem()) {
+ assumeRecoveryThroughClientTransactionID(false);
+ AbfsDfsClient abfsDfsClient = (AbfsDfsClient)
Mockito.spy(fs.getAbfsClient());
+ fs.getAbfsStore().setClient(abfsDfsClient);
+ final String[] clientTransactionId = new String[1];
+ mockAddClientTransactionIdToHeader(abfsDfsClient, clientTransactionId);
+ mockRetriedRequest(abfsDfsClient, new ArrayList<>());
+ boolean[] flag = new boolean[1];
+ Mockito.doAnswer(getPathStatus -> {
+ if (!flag[0]) {
+ flag[0] = true;
+ throw new AbfsRestOperationException(HTTP_CLIENT_TIMEOUT, "", "",
new Exception());
+ }
+ return getPathStatus.callRealMethod();
+ }).when(abfsDfsClient).getPathStatus(
+ Mockito.nullable(String.class), Mockito.nullable(Boolean.class),
+ Mockito.nullable(TracingContext.class),
+ Mockito.nullable(ContextEncryptionAdapter.class));
+
+ Path sourceDir = path("/testSrc");
+ assertMkdirs(fs, sourceDir);
+ String filename = "file1";
+ Path sourceFilePath = new Path(sourceDir, filename);
+ touch(sourceFilePath);
+ Path destFilePath = new Path(sourceDir, "file2");
+
+ String errorMessage = intercept(AbfsDriverException.class,
+ () -> fs.rename(sourceFilePath, destFilePath)).getErrorMessage();
+
+ Assertions.assertThat(errorMessage)
+ .describedAs("getPathStatus should fail while recovering")
+ .contains("Error in getPathStatus while recovering from rename
failure.");
Review Comment:
Done
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemRename.java:
##########
@@ -1641,4 +1653,180 @@ public void
testRenameSrcDirDeleteEmitDeletionCountInClientRequestId()
Mockito.any(TracingContext.class));
fs.rename(new Path(dirPathStr), new Path("/dst/"));
}
+
+ /**
+ * Test to verify the idempotency of the `rename` operation in Azure Blob
File System when retrying
+ * after a failure. The test simulates a "path not found" error (HTTP 404)
on the first attempt,
+ * checks that the operation correctly retries using the appropriate
transaction ID,
+ * and ensures that the source file is renamed to the destination path once
successful.
+ *
+ * @throws Exception if an error occurs during the file system operations or
mocking
+ */
+ @Test
+ public void renamePathRetryIdempotency() throws Exception {
Review Comment:
Done
> [ABFS] Rename/Create path idempotency client-level resolution
> -------------------------------------------------------------
>
> Key: HADOOP-19450
> URL: https://issues.apache.org/jira/browse/HADOOP-19450
> Project: Hadoop Common
> Issue Type: Task
> Components: fs/azure
> Affects Versions: 3.5.0
> Reporter: Manish Bhatt
> Assignee: Manish Bhatt
> Priority: Major
> Labels: pull-request-available
>
> CreatePath and RenamePath APIs are idempotent as subsequent retries on same
> resource don’t change the server state. However, when client experiences
> connection break on the CreatePath and the RenamePath APIs, client cannot
> make sense if the request is accepted by the server or not.
> On connection failure, the client retries the request. The server might
> return 404 (sourceNotFound) in case of RenamePath API and 409
> (pathAlreadyExists) in case of CreatePath (overwrite=false) API. Now the
> client doesn’t have a path forward. Reason being, in case of CreatePath,
> client doesn’t know if the path was created on the original request or the
> path was already there for some other request, in case of RenamePath, client
> doesn’t know if the source was removed because of the original-try or it was
> not there on the first place.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]