-
Notifications
You must be signed in to change notification settings - Fork 34
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
#65 per-request allocation reduction destroys this module #68
Comments
appleboy
pushed a commit
that referenced
this issue
Mar 1, 2024
* fix: don't race poking logger variable, just make events from it fixes: #68 * fix: need a concurrent buffer to run the current logging test * fix: correct a data race
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #65, in an attempt to reduce allocations, actually wrecks this module and makes the output insane in some cases, and introduces a humongous memory leak.
The problem is that the returned
gin.HandlerFunc
closes overl
the logger variable. Therefore, requests stomp over each other, modifying the same context buffers inside the logger, as a nice data race for good measure, and overall resulting in the data from every request ever issued being captured, leaking memory and making a mess of the output.logger/logger.go
Lines 107 to 113 in 7cff53e
The tests didn't notice this because they all use a
ConsoleWriter
, which obscures this duplication.I think the fix is simple: create an event at that line instead of mutating the logger. Submitted #69 with a fix for this, and a test which demonstrates the issue.
The text was updated successfully, but these errors were encountered: