-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
World age problem with global_logger and tasks launched before logger definition #33865
Comments
Yes it seems increasingly clear that having I think a technical workaround for world age is to have a fixed root logger installed on the root task during system init, and to make this a trivial shim which uses It would be more satisfying to remove |
This seems pretty weird actually and I don't understand why this happens nor whether we can rely on it. But then again, the world age system isn't something I know much about yet. Do you know why this happens? |
This makes sense. Also, I suppose
I have no idea why |
The |
We are still seeing this issue. Is it feasible to just have |
I thought most calls (that the user is permitted to overload) are handled with |
|
Oh interesting. i'm not sure. Fixed on 1.8? Or fixed on master? I'll try to dig up some logs where we've seen this. |
CC: @dewilson, @quinnj and @nickrobinson251 who have all seen this, right? |
For example, here is one we saw today, on julia v1.8.2: ERROR: MethodError: no method matching shouldlog(::TransactionLogging.LocalLogger, ::Base.CoreLogging.LogLevel, ::Module, ::Symbol, ::Symbol)
The applicable method may be too new: running in world age 32015, while current world is 32286.
Closest candidates are:
shouldlog(::TransactionLogging.LocalLogger, ::Any, ::Any, ::Any, ::Any) at ~/packages/TransactionLogging/src/local_logger.jl:52 (method too new to be called from this world context.)
shouldlog(::LoggingExtras.LevelOverrideLogger, ::Any, ::Any...) at ~/.julia/packages/LoggingExtras/5k9PW/src/CompositionalLoggers/overridelogger.jl:17
shouldlog(::LoggingExtras.ActiveFilteredLogger, ::Any...) at ~/.julia/packages/LoggingExtras/5k9PW/src/CompositionalLoggers/activefiltered.jl:37
...
Stacktrace:
[1] _invoked_shouldlog
@ ./logging.jl:78 [inlined]
[2] macro expansion
@ ./logging.jl:381 [inlined]
[3] report_empty_testsets(ti::TestItem, ts::Test.DefaultTestSet)
@ ReTestItems ~/.julia/packages/ReTestItems/Go9Yr/src/log_capture.jl:253
[4] _runtests_in_current_env(shouldrun::Function, paths::Tuple{String}, projectfile::String, nworkers::Int64, nworker_threads::Int64, worker_init_expr::Expr, testitem_timeout::Int64, retries::Int64, verbose_results::Bool, debug::Int64, report::Bool, logs::Symbol)
@ ReTestItems ~/.julia/packages/ReTestItems/Go9Yr/src/ReTestItems.jl:251 |
e84634e. I don't think we are going to be backport it. |
Aha! Thank you, indeed it's been fixed! Neat. :) It's just the one part of the change that we'd need, here: Would we consider that a bug fix? Would it make sense to backport to 1.9.1? |
It seems
global_logger
does not work well with tasks in the following scenario:As an example, running the following code in a fresh
julia
process (i.e., the one that has not importedTerminalLoggers
yet) throws a method error.Output:
Here I'm using https://github.com/c42f/TerminalLoggers.jl (as that's the easiest to set up) but it happens with other packages like https://github.com/oxinabox/LoggingExtras.jl.
Note that uncommenting
# yield()
fixes the problem. So, as a short term solution, is callingyield()
insideglobal_logger(logger)
reasonable? Or maybe implicitly callyield()
afterusing
/import
?As a long term solution, maybe start discouraging the use of
global_logger
and add an API to set up a logger for the RPL, as @c42f suggested in https://discourse.julialang.org/t/different-logging-output-between-juno-execute-and-julia-repl/30933/5? IIUC, with this solution, the task-local logger is inherited to the "background" task at the time it is started and pre-launched tasks will not try to log to the logger that is defined after it is launched. But I'm not 100% sure this is the desired behavior. Maybe it is desirable to be able to swap the logger after it is started?The text was updated successfully, but these errors were encountered: