-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compression in the awskinesisexporter and thread safe #5663
Conversation
compressionPool: sync.Pool{ | ||
New: func() any { | ||
w, err := gzip.NewWriterLevel(nil, gzip.BestSpeed) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return nil on errors? NewWriterLevel
return nil on error itself but I think it's safer if we do the same too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! i forgot that! thanks for reminding, will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, just left one small comment. Will approve though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 LGTM
A suggestion: |
Sounds good! Thanks Foad! I will merge this in so i can build the otel collector and have 2 separate PRs to raise for upstream |
Description
There are two main changes in this PR:
sync.pool
for the compressor so that it is thread safe1st bug
When checking the output of the gzip compressed data, there are errors such as:
This affects zlib, flate and gzip
This is because the
Flush
does not added the EOF markers.Close()
is required be called to mark the EOF.Fix: Changed
Flush
toClose
so that EOF markers are added to end of compressed payload2nd bug
There is a race condition with the compressor because the queued retry allows multiple consumers - see here for documentation
Hence, when there is a retry in the kinesis exporter, it can cause a race condition as the concurrent consumers are reusing the same compressor object
Fix: Used sync.pool to instantiate the compress writers so that it is goroutine safe