-
Notifications
You must be signed in to change notification settings - Fork 529
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 buffer-pooling ingester client #5830
Conversation
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
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, I could see that go test -race
detects raciness when reverting your fix.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
// return them to the pool. | ||
wr.ReturnBuffersToPool() | ||
} | ||
return resp, err |
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.
Do buffers ever get returned to the pool in the case of an error? If not, is that a problem?
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.
No, they don't. When this optimization (buffering client) is disabled, then there's no buffer reuse at all, so overall this is still an improvement.
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.
If enough buffers are not returned to the pool, could it eventually become empty? Maybe instead of returning a buffer to the pool on error, you can inform the pool that it has an empty slot?
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.
Pool also starts empty. If an existing buffer cannot be retrieved from the pool, new buffer is allocated, and then put into the pool when not used anymore.
What this PR does
This PR fixes data race caused by using buffer-pooling ingester client, originally introduced in #5195. Before this PR the client would always return buffers to the pool. However in case of context cancellations buffers could still be enqueued for sending inside gRPC client, and returning them back to pool would cause data race.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]