graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

Try fixing memory leak for syslog input

Open fpetersen-gl opened this issue 1 month ago • 0 comments

Usually the netty-component calling a retain() on a ByteBuf is also responsible for release()ing it. Until now, there is a retain() in the SyslogTCPFramingRouterHandler, but we only release() it in case of an exception. This is on purpose, as when it comes to multi-frame messages, the first part(s) of the message were already released and thus not accessible, when the decoder is trying to do its job.

Now, we keep track of all messages we retain() and release them once the channel (usually network-connection) is closed or an exception occurs. That way we can be sure to release all allocated buffers, while keeping the buffers around for long enough to also be able to decode them correctly.

Things to verify:

  • [ ] Is the SyslogTCPFramingRouterHandler a singleton (possible threading-issues on the collection of retainedBuffers)?

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Refactoring (non-breaking change)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have requested a documentation update.
  • [ ] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.

fpetersen-gl avatar Dec 11 '25 13:12 fpetersen-gl