Skip to content

Close file InputStreams when copying segments#516

Merged
jeqo merged 1 commit intomainfrom
ivanyu/fix-input-files-closing
Mar 26, 2024
Merged

Close file InputStreams when copying segments#516
jeqo merged 1 commit intomainfrom
ivanyu/fix-input-files-closing

Conversation

@ivanyu
Copy link
Copy Markdown
Contributor

@ivanyu ivanyu commented Mar 16, 2024

Closes #513

It's easier to review RemoteStorageManager.java if you hide white spaces in Github or your IDE.

@ivanyu ivanyu mentioned this pull request Mar 16, 2024
@ivanyu ivanyu force-pushed the ivanyu/fix-input-files-closing branch 6 times, most recently from 5dce06e to ad75b20 Compare March 16, 2024 14:24
@ivanyu ivanyu marked this pull request as ready for review March 16, 2024 14:31
@ivanyu ivanyu requested a review from a team as a code owner March 16, 2024 14:31
Copy link
Copy Markdown
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jeqo
jeqo previously approved these changes Mar 19, 2024
Copy link
Copy Markdown
Contributor

@jeqo jeqo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nicely solved.

Thanks @funky-eyes for reporting, and @ivanyu for the fix!

@funky-eyes
Copy link
Copy Markdown
Contributor

funky-eyes commented Mar 21, 2024

Hi @jeqo when can this PR be merged?

new TransformFinisher(transformEnum, remoteLogSegmentMetadata.segmentSizeInBytes());
uploadSegmentLog(remoteLogSegmentMetadata, transformFinisher, customMetadataBuilder);

final ChunkIndex chunkIndex = transformFinisher.chunkIndex();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not it be so that the lifecycle of transformFinisher should be same as logSementInputStream? Saving chunkIndex into filed in rather a side effect, it is safe to get it here but the main purpose of the finisher is based on the underlying stream that is already closed afaiu. So I'd rather would not expose finisher from the try related to underlying stream or maybe would even try to make it auto closeable(not sure if it's possible) and close simultaneously with the underlying stream.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe because chunkIndex() is designed be called after the processing (otherwise IllegalStateException will be thrown). However, I moved TransformFinisher inside the try, have a look at the fixup.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM but not sure if we need a nested try, imo it could be just single one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please squash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ivanyu ivanyu force-pushed the ivanyu/fix-input-files-closing branch from d5c3767 to 8a86fee Compare March 26, 2024 12:17
@jeqo jeqo merged commit 8961b62 into main Mar 26, 2024
@jeqo jeqo deleted the ivanyu/fix-input-files-closing branch March 26, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disk space not released

4 participants