bhattmanish98 commented on code in PR #7509: URL: https://github.com/apache/hadoop/pull/7509#discussion_r2024677585
########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java: ########## @@ -1691,4 +1555,297 @@ public String addClientTransactionIdToHeader(List<AbfsHttpHeader> requestHeaders } return clientTransactionId; } + + /** + * Attempts to rename a path with client transaction ID (CTId) recovery mechanism. + * If the initial rename attempt fails, it tries to recover using CTId or ETag + * and retries the operation. + * + * @param source the source path to be renamed + * @param destination the destination path for the rename + * @param continuation the continuation token for the operation + * @param tracingContext the context for tracing the operation + * @param sourceEtag the ETag of the source path for conditional requests + * @param isMetadataIncompleteState flag indicating if the metadata state is incomplete + * @return an {@link AbfsClientRenameResult} containing the result of the rename operation + * @throws IOException if an error occurs during the rename operation + */ + private AbfsClientRenameResult renameWithCTIdRecovery(String source, + String destination, String continuation, TracingContext tracingContext, + String sourceEtag, boolean isMetadataIncompleteState) throws IOException { + // Get request headers for rename operation + List<AbfsHttpHeader> requestHeaders = getHeadersForRename(source); + // Add client transaction ID to the request headers + String clientTransactionId = addClientTransactionIdToHeader(requestHeaders); + + // Create the URL for the rename operation + final URL url = createRequestUrl(destination, + getRenameQueryBuilder(destination, continuation).toString()); + + // Create the rename operation + AbfsRestOperation op = createRenameRestOperation(url, requestHeaders); + try { + incrementAbfsRenamePath(); + op.execute(tracingContext); + // If we successfully rename a path and isMetadataIncompleteState is true, + // then the rename was recovered; otherwise, it wasn’t. + // This is why isMetadataIncompleteState is used for renameRecovery (as the second parameter). + return new AbfsClientRenameResult(op, isMetadataIncompleteState, + isMetadataIncompleteState); + } catch (AzureBlobFileSystemException e) { + // Handle rename exceptions and retry if applicable + handleRenameException(source, destination, continuation, Review Comment: Yes, it is the existing code where in case we get RENAME_DESTINATION_PARENT_PATH_NOT_FOUND error from server, we retrigger the rename operation after fetching src etag value. Recovery happens in case server error is SOURCE_PATH_NOT_FOUND. ``` // ref: HADOOP-18242. Rename failure occurring due to a rare case of // tracking metadata being in incomplete state. -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org