Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8307d83
DataWriter - failure to close should not create a dataFile on future …
Jul 20, 2022
a29b6f0
remove test case which was not needed
Jul 20, 2022
f91928e
fix spelling
Jul 20, 2022
ed2493b
remove wildcards
Jul 20, 2022
ffe6d55
Fix BaseTaskWriter to clear currentWriter on close
Jul 20, 2022
d70bf5d
fix formatting
Jul 20, 2022
5820a11
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
4551012
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
ff2f362
revert changes and bring back the original fix in S3OutputStream
Jul 26, 2022
fbe8b0f
fix checkstyle
Jul 26, 2022
11d4f71
DataWriter - failure to close should not create a dataFile on future …
Jul 20, 2022
232c25c
remove test case which was not needed
Jul 20, 2022
6bd739f
fix spelling
Jul 20, 2022
1ed2311
Fix BaseTaskWriter to clear currentWriter on close
Jul 20, 2022
c8da6ad
fix formatting
Jul 20, 2022
9e8639d
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
3d35019
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
b80a18c
revert changes and bring back the original fix in S3OutputStream
Jul 26, 2022
8e3b16d
fix checkstyle
Jul 26, 2022
41fe105
Merge branch 'master' of https://github.com/abmo-x/iceberg
Jul 29, 2022
12cd1ac
squash commits
Jul 29, 2022
0cfb46c
Merge branch 'master' of https://github.com/abmo-x/iceberg
Jul 29, 2022
5bab962
spotless apply
Jul 29, 2022
f0bca0d
Merge branch 'apache:master' into master
abmo-x Jul 29, 2022
514d325
Update S3OutputStream.java
abmo-x Aug 2, 2022
cee882c
API: Track name and unit in Counter, Timer (#5386)
nastra Jul 30, 2022
3f210ca
Python: Add REST catalog implementation (#5287)
Fokko Jul 30, 2022
89423a6
Flink: Produce Flink metrics directly (#5393)
stevenzwu Jul 30, 2022
5f6ffb7
Python: Bump fastavro from 1.5.3 to 1.5.4 in /python (#5396)
dependabot[bot] Jul 31, 2022
0a91c64
Github: Add issue form (#4867)
Fokko Jul 31, 2022
1d5797f
Build: Add an action to handle stale Github issues (#4949)
kbendick Jul 31, 2022
4b18827
Flink: Support write options in the in-line SQL comments (#5050)
hililiwei Aug 1, 2022
4b55b40
AWS: Call abortUpload only once when any of the completable future fa…
singhpk234 Aug 1, 2022
090fe1b
Spark: Implement FunctionCatalog (#5377)
kbendick Aug 1, 2022
704348a
Python: Refactor expression hierarchy (#5389)
rdblue Aug 1, 2022
b7afcf3
API: Fix ID assignment in schema merging (#5395)
karuppayya Aug 1, 2022
d454211
Spark 3.2: Backport FunctionCatalog to Spark 3.2 (#5411)
kbendick Aug 1, 2022
47126ba
Nessie: Bump to 0.40.3 (#5406)
snazy Aug 1, 2022
a6f157a
Python: Minor REST catalog updates (#5402)
Fokko Aug 1, 2022
b9e043b
apply spotcheck
Aug 2, 2022
5e16378
squash commits
Jul 29, 2022
b0a8472
DataWriter - failure to close should not create a dataFile on future …
Jul 20, 2022
0889ecd
remove test case which was not needed
Jul 20, 2022
c8f3472
Fix BaseTaskWriter to clear currentWriter on close
Jul 20, 2022
532e532
fix formatting
Jul 20, 2022
7802ad7
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
7d3ed0c
revert changes and bring back the original fix in S3OutputStream
Jul 26, 2022
82b557d
fix checkstyle
Jul 26, 2022
893ea9e
DataWriter - failure to close should not create a dataFile on future …
Jul 20, 2022
c16540e
remove test case which was not needed
Jul 20, 2022
be418cd
Fix BaseTaskWriter to clear currentWriter on close
Jul 20, 2022
c80f403
fix formatting
Jul 20, 2022
1a8892d
remove rethrow from close on a closed stream to keep the api consistent
Jul 25, 2022
cbf3e37
revert changes and bring back the original fix in S3OutputStream
Jul 26, 2022
9cd1a14
fix checkstyle
Jul 26, 2022
f8fa06b
spotless apply
Jul 29, 2022
268f9ac
Update S3OutputStream.java
abmo-x Aug 2, 2022
fee329e
apply spotcheck
Aug 2, 2022
bd28e25
Merge branch 'master' of https://github.com/abmo-x/iceberg
Aug 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion aws/src/main/java/org/apache/iceberg/aws/s3/S3OutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class S3OutputStream extends PositionOutputStream {

private long pos = 0;
private boolean closed = false;
private Throwable closeFailureException;

@SuppressWarnings("StaticAssignmentInConstructor")
S3OutputStream(S3Client s3, S3URI location, AwsProperties awsProperties, MetricsContext metrics)
Expand Down Expand Up @@ -258,6 +259,15 @@ private void newStream() throws IOException {

@Override
public void close() throws IOException {

// A failed s3 close removes state that is required for a successful close.
// Any future close on this stream should fail.
if (closeFailureException != null) {
throw new IOException(
"Attempted to close an S3 output stream that failed to close earlier",
closeFailureException);
}

if (closed) {
return;
}
Expand All @@ -267,8 +277,10 @@ public void close() throws IOException {

try {
stream.close();

completeUploads();
} catch (Exception e) {
closeFailureException = e;
throw e;
} finally {
cleanUpStagingFiles();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -181,6 +182,24 @@ public void testWriteWithChecksumEnabled() {
writeTest();
}

@Test
public void testCloseFailureShouldPersistOnFutureClose() throws IOException {
IllegalStateException mockException =
new IllegalStateException("mock failure to completeUploads on close");
Mockito.doThrow(mockException)
.when(s3mock)
.putObject(any(PutObjectRequest.class), any(RequestBody.class));
S3OutputStream stream = new S3OutputStream(s3mock, randomURI(), properties, nullMetrics());

Assertions.assertThatThrownBy(stream::close)
.isInstanceOf(mockException.getClass())
.hasMessageContaining(mockException.getMessage());

Assertions.assertThatThrownBy(stream::close)
.isInstanceOf(IOException.class)
.hasCause(mockException);
}

private void writeTest() {
// Run tests for both byte and array write paths
Stream.of(true, false)
Expand Down