-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fixed deadlock when rolling the file under a heavy load #24980
Conversation
dmatej
commented
Jun 5, 2024
- Fixed LogRecordBuffer configuration - it always used defaults
- That caused overload without any possibility to configure maxWaitTime or increase the buffer size
- Fixed deadlock - don't use loggers in critical section.
- Deadlock can be caused when we are rolling the file with the full log record buffer AND we log anything from this thread.
- Solution: if you really need to log something, use asynchronous thread.
- Under a heavy load (1 record every 3 microseconds) such log record can occur even after another 5000 other records in the buffer or trying to be added to the buffer. It is just another one. Usually it will be the first one.
- Moving from synchronized to reentrant locks + fixed deadlock
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- when buffer is full, every new log will be blocked. If this happens for records comming from the thread moving the server.log file, everything stops forever. Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Deadlock can be caused when we are rolling the file with the full log record buffer AND we log anything from this thread. - Solution: if you really need to log something, use asycnhronous thread. - Under a heavy load (1 record every 3 microseconds) such log record can occur even after another 5000 other records in the buffer or trying to be added to the buffer. It is just another one. Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
...us/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java
Outdated
Show resolved
Hide resolved
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.
The old code did not guarantee visibility of variables. Each new thread could see the old values (or mix from old and new values) and do reconfiguration.
This code is now safe, although somewhat slower :)
Hmmm, if we move check under write lock, we have deadlock... UPD. |
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Good lesson, I read the javadoc again, and also - I should never push without running tests of the module at least. |
Well, now I passed tests, but I did some manual testing and I have another deadlock. Also I see too many logging pumps for STDOUT+STDERR, seems after every reconfiguration it creates another ... EDIT: Oh, I got it. Those pollOrWait are waiting forever locked, so we can never get the write lock! And I forgot also about the possibility to decrease the size of the full buffer. |
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>