Skip to content
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: fix memory leak in endpoint buffer #808

Merged
merged 6 commits into from
Dec 21, 2024
Merged

Conversation

luke-lombardi
Copy link
Contributor

NOTE: Still need to reproduce this locally before merging

@@ -30,7 +32,7 @@ func (t *EndpointTask) Execute(ctx context.Context, options ...interface{}) erro
return err
}

return instance.buffer.ForwardRequest(echoCtx, t)
return instance.buffer.ForwardRequest(echoCtx, t, payload)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a little hacky, but it makes sure that endpoint request payloads don't get stored in redis along with the rest of the task message. Since endpoint tasks don't support retries, this isn't necessary and wastes redis memory.

@@ -176,6 +173,11 @@ func (rb *RequestBuffer) processRequests() {
continue
}

if req.ctx.Request().Context().Err() != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the client hung up by the time we're handling this request (error is not nil even if the context is just cancelled), then we should just mark this task as canceled and move on to the next item in the request buffer.

@luke-lombardi luke-lombardi merged commit b36b742 into main Dec 21, 2024
3 checks passed
@luke-lombardi luke-lombardi deleted the ll/fix-memory-leak branch December 21, 2024 22:11
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.

2 participants