You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ho...@apache.org on 2023/09/04 15:16:12 UTC
[flink] branch release-1.17 updated: [FLINK-28513] Fix Flink Table API CSV streaming sink throws
This is an automated email from the ASF dual-hosted git repository.
hong pushed a commit to branch release-1.17
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.17 by this push:
new d06a297422f [FLINK-28513] Fix Flink Table API CSV streaming sink throws
d06a297422f is described below
commit d06a297422fd4884aa21655fdf1f1bce94cc3a8a
Author: Samrat002 <de...@gmail.com>
AuthorDate: Mon Sep 4 16:59:45 2023 +0530
[FLINK-28513] Fix Flink Table API CSV streaming sink throws
---
.../fs/s3/common/writer/S3RecoverableFsDataOutputStream.java | 11 ++++++++++-
.../s3/common/writer/S3RecoverableFsDataOutputStreamTest.java | 10 ++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStream.java b/flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStream.java
index 8cce4ce44c4..49130aeecdd 100644
--- a/flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStream.java
+++ b/flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStream.java
@@ -126,7 +126,16 @@ public final class S3RecoverableFsDataOutputStream extends RecoverableFsDataOutp
@Override
public void sync() throws IOException {
- fileStream.sync();
+ lock();
+ try {
+ fileStream.flush();
+ openNewPartIfNecessary(userDefinedMinPartSize);
+ Committer committer = upload.snapshotAndGetCommitter();
+ committer.commitAfterRecovery();
+ closeForCommit();
+ } finally {
+ unlock();
+ }
}
@Override
diff --git a/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStreamTest.java b/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStreamTest.java
index 5c7156513b5..29193dceb6b 100644
--- a/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStreamTest.java
+++ b/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/writer/S3RecoverableFsDataOutputStreamTest.java
@@ -254,6 +254,16 @@ public class S3RecoverableFsDataOutputStreamTest {
streamUnderTest.closeForCommit().commit();
}
+ @Test(expected = Exception.class)
+ public void testSync() throws IOException {
+ streamUnderTest.write(bytesOf("hello"));
+ streamUnderTest.write(bytesOf(" world"));
+ streamUnderTest.sync();
+ assertThat(multipartUploadUnderTest, hasContent(bytesOf("hello world")));
+ streamUnderTest.write(randomBuffer(RefCountedBufferingFileStream.BUFFER_SIZE + 1));
+ assertThat(multipartUploadUnderTest, hasContent(bytesOf("hello world")));
+ }
+
// ------------------------------------------------------------------------------------------------------------
// Utils
// ------------------------------------------------------------------------------------------------------------