SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
possibly fix concurrent access to entry object in SeaweedOutputStream
Chris Lu222f93e8166e
diff --git a/LICENSE b/LICENSEindex 735f67b68f..abdba6d606 100644--- a/LICENSE+++ b/LICENSE@@ -1,4 +1,4 @@- Apache License+g Apache LicenseVersion 2.0, January 2004http://www.apache.org/licenses/diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.javaindex dc6203e52f..18ec77b767 100644--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java@@ -45,28 +45,32 @@ public class SeaweedWrite {String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey);+ synchronized (entry) {+ entry.addChunks(FilerProto.FileChunk.newBuilder()+ .setFileId(fileId)+ .setOffset(offset)+ .setSize(bytesLength)+ .setMtime(System.currentTimeMillis() / 10000L)+ .setETag(etag)+ .setCipherKey(cipherKeyString)+ );+ }+// cache fileId ~ bytesSeaweedRead.chunkCache.setChunk(fileId, bytes);- entry.addChunks(FilerProto.FileChunk.newBuilder()- .setFileId(fileId)- .setOffset(offset)- .setSize(bytesLength)- .setMtime(System.currentTimeMillis() / 10000L)- .setETag(etag)- .setCipherKey(cipherKeyString)- );-}public static void writeMeta(final FilerGrpcClient filerGrpcClient,final String parentDirectory, final FilerProto.Entry.Builder entry) {- filerGrpcClient.getBlockingStub().createEntry(- FilerProto.CreateEntryRequest.newBuilder()- .setDirectory(parentDirectory)- .setEntry(entry)- .build()- );+ synchronized (entry){+ filerGrpcClient.getBlockingStub().createEntry(+ FilerProto.CreateEntryRequest.newBuilder()+ .setDirectory(parentDirectory)+ .setEntry(entry)+ .build()+ );+ }}private static String multipartUpload(String targetUrl,diff --git a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.javaindex 7b488a5da4..e08843caae 100644--- a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java+++ b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java@@ -69,9 +69,6 @@ public class SeaweedOutputStream extends OutputStream {}private synchronized void flushWrittenBytesToServiceInternal(final long offset) throws IOException {-- LOG.debug("SeaweedWrite.writeMeta path: {} entry:{}", path, entry);-try {SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);} catch (Exception ex) {diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.javaindex 4f307ff962..96af27fe03 100644--- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java+++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java@@ -78,9 +78,6 @@ public class SeaweedOutputStream extends OutputStream implements Syncable, Strea}private synchronized void flushWrittenBytesToServiceInternal(final long offset) throws IOException {-- LOG.debug("SeaweedWrite.writeMeta path: {} entry:{}", path, entry);-try {SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);} catch (Exception ex) {