From 0f2ac71e399573d221fcb3c64ed3656ecf677ea3 Mon Sep 17 00:00:00 2001 From: vintmd <61688729+vintmd@users.noreply.github.com> Date: Tue, 31 Jan 2023 20:40:25 +0800 Subject: [PATCH] remove conflict check switch (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: alantong(佟明达) --- .../org/apache/hadoop/fs/CosNConfigKeys.java | 3 -- .../hadoop/fs/CosNativeFileSystemStore.java | 34 ++++++++----------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java index 8e92e9ef..c7023677 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java +++ b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java @@ -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; } diff --git a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java index e9c42e35..49160866 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java +++ b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java @@ -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); @@ -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, "