-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Log] make glog flush and RAY_LOG thread-safe #11002
Conversation
It's runnning as same as previous version in my laptop. @mehrdadn Could you double check the log destination file and directory? We'd better make the proper log files end up in the proper folder. (also works well Windows) |
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.
AFAIK, GLOG has already done locking here, so we don't need to worry about thread-safety in custom loggers.
Glog guarantees base logger thread safe by holding muted lock inside. But we cannot assert it works well definitely. For example, other thread is logging somethings to destination file when stream logger singleton has been closed in ShutdownRayLog before invoking glog shutdown. |
I agree that ShutdownRayLog is not thread-safe.
…On Sep 25, 2020, 01:42 +0800, Lingxuan Zuo ***@***.***>, wrote:
> AFAIK, GLOG has already done locking here, so we don't need to worry about thread-safety in custom loggers.
Glog guarante base logger thread safe by holding muted lock inside. But we cannot assert it works well definitely. For example, other thread is logging somethings to destination file when stream logger singleton has been closed in ShutdownRayLog before invoking glog shutdown.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
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.
Please wait for @mehrdadn's comments since you are trying to remove StreamLogger
.
@mehrdadn Could you explain the motivation of replacing the default logger with |
@kfstorm It was just to combine messages of different severities into the same log files (#9230), because my previous changes had resulted in them going into separate log files. The previous changes were trying to make sure that the log files were in the correct log directory (because in some cases logs used to be created in the wrong folder). |
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.
@ashione To be honest glog was quite a headache for me to figure out and I only touched it incidentally (and at this point I've forgotten some details already). Also, I've actually stopped working on Ray. You might want to reach out to others for reviewing haha.
Sorry to hear that. But thanks a lot for your response. |
I find these comments in glog/logging.cc
So raylet's log will be printed in /tmp with ...log.. format. |
@ashione I see. So to fix the wrong log folder issue, can we just apply a patch to the GLOG source code to disable the "default base filename" feature? Then we can revert logging.cc to the version several months ago. |
I must say that the logging to "/tmp" by default behavior is a really bad design. And it even can't be turned off. 🤷♂️ |
@mehrdadn is this "in some cases logs used to be created in the wrong folder" you met earlier? |
It's only extra log file on linux machine. Finally I fix it by mapping all severities to destination. |
By the way, not sure if this is relevant to what you're doing, but here's a repro I had for an issue where different severities would end up in different log files (and it explains why I used |
Just set up all other levels of logging to empty destination. So there should be no such log files left by now. |
But none of logging items can be redirected to raylet.out. Glog will print all of logs in stderr. |
I can't open the second snapshot figure. Could you upload it again? |
|
@rkooo567 A new pytest case for checking raylet.out/raylet.err has been added. |
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.
We'd better check for worker logs as well.
# Make subprocess happy in bazel. | ||
os.environ["LC_ALL"] = "en_US.UTF-8" | ||
os.environ["LANG"] = "en_US.UTF-8" |
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.
Why we need these? I can't find them in
ray/python/ray/tests/test_advanced.py
Lines 512 to 514 in b5ecdd0
if __name__ == "__main__": | |
import pytest | |
sys.exit(pytest.main(["-v", __file__])) |
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.
I think this is needed for ray_start_regular (because of some click dependency issues)
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.
I just paste them from test_ouput.py.
Seems like there are memory corruption (look at asan test) and lint failure! Once you resolved these, I will test locally again and approve! |
It's fixed in latest commit. |
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.
Let me test locally one last time before we merge.
Btw, this is a really nice fix :). I always wondered why we have multiple Error logs haha |
Because INFO and more high level logs will be written to info-log-file, and WARN and its more higher level also could be printed in warn-log-file, warn-logs have been recorded twice when info-log-file and warn-log-file are same destination. |
Okay. Confirm it looks great :) |
Please add the |
I'll check travis failures. |
Current RAY_LOG will make duplicated output in log files.
For example, all logs of RAY_LOG(ERROR) will be flushed three times to destination file since we use a same sink file for INFO, WARN and ERROR level.
More important thing is this implementation is not thread-safe, so we'd better use glog default logobject.
Why are these changes needed?
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.