Skip to content

Commit

Permalink
remove conflict check switch (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: alantong(佟明达) <[email protected]>
  • Loading branch information
vintmd and vintmd authored Jan 31, 2023
1 parent 789b652 commit 0f2ac71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
3 changes: 0 additions & 3 deletions src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,4 @@ public class CosNConfigKeys extends CommonConfigurationKeys {

public static final String COSN_FILESTATUS_LIST_OP_ENABLED = "fs.cosn.filestatus.list.op.enabled";
public static final boolean DEFAULT_FILESTATUS_LIST_OP_ENABLED = true;

public static final String COSN_PART_CONFLICT_CHECK_ENABLED = "fs.cosn.part.conflict.check.enabled";
public static final boolean DEFAULT_COSN_PART_CONFLICT_CHECK_ENABLED = true;
}
34 changes: 14 additions & 20 deletions src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ private void initCOSClient(URI uri, Configuration conf) throws IOException {
CosNConfigKeys.DEFAULT_CRC32C_CHECKSUM_ENABLED);
this.completeMPUCheckEnabled = conf.getBoolean(CosNConfigKeys.COSN_COMPLETE_MPU_CHECK,
CosNConfigKeys.DEFAULT_COSN_COMPLETE_MPU_CHECK_ENABLE);
this.partConflictCheckEnabled = conf.getBoolean(CosNConfigKeys.COSN_PART_CONFLICT_CHECK_ENABLED,
CosNConfigKeys.DEFAULT_COSN_PART_CONFLICT_CHECK_ENABLED);
this.clientEncryptionEnabled = conf.getBoolean(CosNConfigKeys.COSN_CLIENT_SIDE_ENCRYPTION_ENABLED,
CosNConfigKeys.DEFAULT_COSN_CLIENT_SIDE_ENCRYPTION_ENABLED);

Expand Down Expand Up @@ -570,26 +568,22 @@ public PartETag uploadPart(InputStream inputStream, String key, String uploadId,
String errMsg = String.format("The current thread:%d, "
+ "cos key: %s, upload id: %s, part num: %d, exception: %s",
Thread.currentThread().getId(), key, uploadId, partNum, cse);
if (!this.partConflictCheckEnabled) {
handleException(new Exception(errMsg), key);
} else {
int statusCode = cse.getStatusCode();
if (409 == statusCode) {
// conflict upload same upload part, because of nginx syn retry,
// sometimes 31s reconnect to cgi, but client side default 30s timeout,
// which may cause the retry request and previous request arrive at cgi at same time.
// so we for now use list parts to double-check this part whether exist.
CosNPartListing partListing = listParts(key, uploadId);
PartETag partETag = isPartExist(partListing, partNum, partSize);
if (null == partETag) {
handleException(new Exception(errMsg), key);
}
LOG.warn("Upload the file [{}] uploadId [{}], part [{}] concurrently." +
key, uploadId, partNum);
return partETag;
} else {
int statusCode = cse.getStatusCode();
if (409 == statusCode) {
// conflict upload same upload part, because of nginx syn retry,
// sometimes 31s reconnect to cgi, but client side default 30s timeout,
// which may cause the retry request and previous request arrive at cgi at same time.
// so we for now use list parts to double-check this part whether exist.
CosNPartListing partListing = listParts(key, uploadId);
PartETag partETag = isPartExist(partListing, partNum, partSize);
if (null == partETag) {
handleException(new Exception(errMsg), key);
}
LOG.warn("Upload the file [{}] uploadId [{}], part [{}] concurrently." +
key, uploadId, partNum);
return partETag;
} else {
handleException(new Exception(errMsg), key);
}
} catch (Exception e) {
String errMsg = String.format("The current thread:%d, "
Expand Down

0 comments on commit 0f2ac71

Please sign in to comment.