Repository navigation
Fix OOM by closing writer immediately in one-record-per-file mode - #651
Merged
aindriu-aiven merged 4 commits intoNov 25, 2026
Merged
Conversation
tanbt
marked this pull request as draft
November 19, 2026 09:32
tanbt
force-pushed
the
tanbt/gcs-connector-one-writer-per-file-FLEET-6932
branch
from
November 19, 2026 22:12
f114f7b to
57d7a95
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A failed write skips cleanup and discards the writer, leaking upload and formatting resources while processing continues; failure-safe cleanup and a multi-file failure test are needed.
1 open issue
What changed in this PR
This PR reduces upload-buffer memory pressure in the GCS sink connector by closing completed file writers immediately rather than retaining them until flush ends.
Changes:
- Close writers after each write for key-based one-record-per-file grouping and positive record-limit configurations.
- Add channel-counting tests for both modes, including file contents and rotation across intermediate writes.
| File | Description |
|---|---|
gcs-sink-connector/src/test/java/io/aiven/kafka/connect/gcs/GcsSinkTaskTest.java |
Adds writer-lifetime and record-limit rotation tests. |
gcs-sink-connector/src/main/java/io/aiven/kafka/connect/gcs/GcsSinkTask.java |
Adds immediate writer closure for eligible grouping modes. |
Review effort: Balanced
tanbt
force-pushed
the
tanbt/gcs-connector-one-writer-per-file-FLEET-6932
branch
2 times, most recently
from
November 20, 2026 10:39
6463d10 to
f9707b2
Compare
tanbt
force-pushed
the
tanbt/gcs-connector-one-writer-per-file-FLEET-6932
branch
from
November 23, 2026 09:17
f9707b2 to
15a8f0c
Compare
Avoids holding one upload buffer per file until flush, which could cause OOM with key-based file name templates. Also close the previous writer when file.max.records is set and a new file is started, ensuring one writer at a time.
Avoids holding one upload buffer per file until flush, which could cause OOM with key-based file name templates. Also close the previous writer when file.max.records is set and a new file is started, ensuring one writer at a time.
Avoids holding one upload buffer per file until flush, which could cause OOM with key-based file name templates. Also close the previous writer when file.max.records is set and a new file is started, ensuring one writer at a time.
tanbt
force-pushed
the
tanbt/gcs-connector-one-writer-per-file-FLEET-6932
branch
from
November 24, 2026 16:46
15a8f0c to
5cb4caa
Compare
tanbt
marked this pull request as ready for review
November 25, 2026 07:07
aindriu-aiven
approved these changes
Nov 25, 2026
aindriu-aiven
left a comment
Contributor
There was a problem hiding this comment.
LGTM thanks @tanbt
Still only sends them on flush but makes sure we keep the memory in check with the number of active clients for single file writes 👍
aindriu-aiven
deleted the
tanbt/gcs-connector-one-writer-per-file-FLEET-6932
branch
November 25, 2026 15:09
Merged
aindriu-aiven
added a commit
that referenced
this pull request
Dec 2, 2026
Proposed changelog: # Changes - [fix(s3-sink-connector): sse algorithm properties ](#648) - [fix(s3-sink-connector) close S3 client on task stop ](#649) - [Fix offset position for s3 source connector](75ab69c) - [Part size configuration to allow users to define the part size used in s3 sink connector](fb275fe) - [Fix OOM by closing writer immediately in one-record-per-file mode ](#651) - [Upgrade schema registry container to 6.2.4 ](#654] # First Time Contributers - [avoidik](https://github.com/avoidik) [Viacheslav Vasilyev](https://github.com/avoidik) - [binshuohu](https://github.com/binshuohu) [Binshuo Hu](https://github.com/binshuohu)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Currently, writers in
activeBlobWritersare only closed afterwards, in the loop at the end of flush(). At that point all N writers are open at once, which gives N × ~16 MB of buffers. This usually causes OOM for example withfile.name.template={{key}}which is one record per file.Solution:
Since a one-record file is complete as soon as its single write finishes, the writer can be closed right away, so that only one 16 MB buffer is alive at a time.
Skip:
A topic with huge amount of partitions could also hit this OOM. For example, a node of 4GB memory has ~2GB heap could hit it with a topic of ~128 partitions (2*1024/16).