-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-8981][CORE][test-hadoop3.2][test-java11] Add MDC support in Executor #26624
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
Conversation
|
@dongjoon-hyun Could you review that, please? |
|
@srowen Hi Could you please look at that? It is very important to me that it will go into spark 3.0.0 |
|
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. |
|
@marmbrus @mojodna @dongjoon-hyun could one of you look at that PR? please I think it will help all users. |
|
yes - please approve. we need this as well |
|
+1, welcomed addition for adding more context to our current logs |
|
@cloud-fan Could you please look at that? |
|
cc @Ngone51 |
Ngone51
left a comment
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.
This looks useful to me. But could we reduce the scope from the beginning, e.g. TaskRunner only. ThreadUtils seems to have many impact.
And it seem we also need to add pattern configuration for MDC? Otherwise, it doesn't work(I tried it locally).
|
Hi, @Ngone51 first thank for reviewing! |
Could you give a pattern configuration template to make MDC work with Spark? IIUC, the configuration is related to the
So you internally use MDC to track logs at application level? (IIUC, |
|
log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %p [%X{appId}] [%X{appName}] %c{3} - %m%n in that code you iterate over the properties and add each property that start with mdc it adds to MDC so you can use. we are using spark under spark server so we have long-running sessions and many tasks in it that do not connect to each other. and we add properties so we can see in the logs which connected to which. |
|
ok to test |
|
Test build #121949 has finished for PR 26624 at commit
|
|
This looks like a good feature. Can we split it into several smaller PRs? e.g. the first PR can just focus on the TaskRunner. |
|
Hi @cloud-fan, I think that if we will not merge all as part it will not have the benefit. as I answer in an earlier comment |
Sorry I can't understand your use case here. From the PR implementation, do you want to know the somewhat relationship between tasks from different applications? Can you explain more about your use case? @igreenfield |
|
we are running one-app but submit to it many tasks using spark-server so it has many tasks that belong to different requests. so in our case, we mostly use the
|
So you're running one application but tasks are running on distributed nodes because of spark-server and logs separately. And you want to collect logs for the application by attaching appId for the task logs, right? |
|
retest this please |
|
Test build #122834 has finished for PR 26624 at commit
|
|
@cloud-fan why the build failed? |
|
retest this please |
|
Test build #122841 has finished for PR 26624 at commit
|
|
@cloud-fan seems like the failing test are not connected to the change... |
|
retest this please |
|
Test build #122849 has finished for PR 26624 at commit
|
|
@cloud-fan What the problem with these tests? |
|
I don't know what's going on, let me retest it on more time |
|
retest this please |
|
Test build #122870 has finished for PR 26624 at commit
|
|
@cloud-fan now all test pass what next? |
|
thanks, merging to master! |
… task ### What changes were proposed in this pull request? This PR is a followup of #26624. This PR cleans up MDC properties if the original value is empty. Besides, this PR adds a warning and ignore the value when the user tries to override the value of `taskName`. ### Why are the changes needed? Before this PR, running the following jobs: ``` sc.setLocalProperty("mdc.my", "ABC") sc.parallelize(1 to 100).count() sc.setLocalProperty("mdc.my", null) sc.parallelize(1 to 100).count() ``` there's still MDC value "ABC" in the log of the second count job even if we've unset the value. ### Does this PR introduce _any_ user-facing change? Yes, user will 1) no longer see the MDC values after unsetting the value; 2) see a warning if he/she tries to override the value of `taskName`. ### How was this patch tested? Tested Manaually. Closes #28756 from Ngone51/followup-8981. Authored-by: yi.wu <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
| `log4j.properties.template` located there. | ||
|
|
||
| By default, Spark adds 1 record to the MDC (Mapped Diagnostic Context): `taskName`, which shows something | ||
| like `task 1.0 in stage 0.0`. You can add `%X{taskName}` to your patternLayout in |
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.
patternLayout -> PatternLayout .
Could you give an example to show how to use it in this document? For example, use an example to show how to specify your application names/identifiers.
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.
@gatorsmile were you able to figure this out? My MDC values are not propagating in my logs after following this same procedure.
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.
@alefischer13 Just a guess, but it looks like this was changed in 54e702c so that the MDC key still includes the mdc. prefix.
|
@igreenfield this does not seem to be working for me. I'm trying to log spark application_id by setting |
|
@alefischer13 Hi please look at this PR that was merged later and changed the way you need to configure the log4j.properties: #28801 |
|
Hi @igreenfield, thanks for the reply. I tried this as well, but it didn't work either. setLocalProperty is working correctly, since I'm able to access the value through getLocalProperty, but |
|
Currently, spark only adds taskName to mdc, can add executorId to MDC as well? https://aws.github.io/aws-emr-containers-best-practices/troubleshooting/docs/where-to-look-for-spark-logs/ |
What changes were proposed in this pull request?
Added MDC support in all thread pools.
ThreaddUtils create new pools that pass over MDC.
Why are the changes needed?
In many cases, it is very hard to understand from which actions the logs in the executor come from.
when you are doing multi-thread work in the driver and send actions in parallel.
Does this PR introduce any user-facing change?
No
How was this patch tested?
No test added because no new functionality added it is thread pull change and all current tests pass.