Skip to content

Commit

Permalink
add complete mpu 409 head retry (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: alantong(佟明达) <[email protected]>
  • Loading branch information
vintmd and vintmd authored May 31, 2022
1 parent da38a2f commit 2d239aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ protected void complete() throws IOException {
throw new IOException("failed to multipart upload to cos, abort it.");
}

// notice sometimes complete result may be null
CompleteMultipartUploadResult completeResult =
nativeStore.completeMultipartUpload(cosKey, this.uploadId, new LinkedList<>(futurePartETagList));
this.completed = true;
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public String getUploadId(String key) throws IOException {
}

/**
* complete cos mpu
* complete cos mpu, sometimes return null complete mpu result
* @param key cos key
* @param uploadId upload id
* @param partETagList each part etag list
Expand All @@ -569,9 +569,28 @@ public int compare(PartETag o1, PartETag o2) {
partETagList);
completeMultipartUploadRequest.setObjectMetadata(objectMetadata);
return (CompleteMultipartUploadResult) this.callCOSClientWithRetry(completeMultipartUploadRequest);
} catch (CosServiceException cse) {
// when first calling with 503 access time out, next retry will 409.
int statusCode = cse.getStatusCode();
if (statusCode == 409) {
// check file whether exist
FileMetadata fileMetadata = this.queryObjectMetadata(key);
if (null == fileMetadata) {
// if file not exist through exception
handleException(cse, key);
}
LOG.warn("Upload the cos key [{}] complete mpu concurrently", key);
} else {
// other exception
String errMsg = String.format("Complete the multipart upload failed. " +
"cos service exception, cos key: %s, upload id: %s, " +
"exception: %s", key, uploadId, cse.toString());
handleException(new Exception(errMsg), key);
}
} catch (Exception e) {
String errMsg = String.format("Complete the multipart upload failed. cos key: %s, upload id: %s, " +
"exception: %s", key, uploadId, e);
String errMsg = String.format("Complete the multipart upload failed. " +
"cos key: %s, upload id: %s, " +
"exception: %s", key, uploadId, e.toString());
handleException(new Exception(errMsg), key);
}
return null;
Expand Down

0 comments on commit 2d239aa

Please sign in to comment.