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

Best way to handle events that are too large for buffering #56

Open
rmelick opened this issue Apr 21, 2016 · 1 comment
Open

Best way to handle events that are too large for buffering #56

rmelick opened this issue Apr 21, 2016 · 1 comment

Comments

@rmelick
Copy link

rmelick commented Apr 21, 2016

When looking through RawSocketSender to troubleshoot our other issue (see comment on #18), I noticed that RawSocketSender does not handle large events very well in send(). It assumes that flush() always makes enough capacity in the pendings buffer to save the new bytes. If the event was bigger than the buffer, you get a BufferOverflowException.

java.nio.BufferOverflowException
    at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:189)
    at java.nio.ByteBuffer.put(ByteBuffer.java:859)
    at org.fluentd.logger.sender.RawSocketSender.send(RawSocketSender.java:171)

Also, if every log message you send is larger than the buffer, then the RawSocketSender will attempt to flush to the socket on every message.

Is this the desired behavior? I could imagine adding a size check to the send() method that immediately returns false if the event is too large, to avoid the BufferOverflowException. Or perhaps the large event could skip the buffer and write directly out to the socket. Since we are already using a BufferedOutputStream, I also wonder why we need the internal pendings buffer at all?

What is the normal way of handling errors in RawSocketSender?

@kidnan1991
Copy link

@rmelick
it is nearly 4 years since then. AFAIK, if you can predict the log message size is bigger than buffer size then you can specific the size when you create the FluentLogger.getLogger()
FluentLogger getLogger(String tagPrefix, String host, int port, int timeout, int bufferCapacity)

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

No branches or pull requests

2 participants