Skip to content

[SPARK-53158][WEBUI] Missing metricsProperties in KV Store should be handled correctly #51887

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thejdeep
Copy link
Contributor

@thejdeep thejdeep commented Aug 6, 2025

[SPARK-53158][WEBUI] Missing metricsProperties in KV Store should be handled correctly

What changes were proposed in this pull request?

When environment property maps (e.g. metricsProperties) are null — often due to LevelDBs created by Spark versions that did not have the property, the Utils.redact(...) function throws a NullPointerException during .map or .toArray operations.

Why are the changes needed?

Without this change, the rest API response of /environment throws a 500 due to the server NullPointerException. The NullPointerException is the following :

Caused by: java.lang.NullPointerException: Cannot invoke "scala.collection.Seq.map(scala.Function1, scala.collection.generic.CanBuildFrom)" because "kvs" is
 null
        at org.apache.spark.util.Utils$.redact(Utils.scala:2923)
        at org.apache.spark.util.Utils$.redact(Utils.scala:2878)
        at org.apache.spark.status.api.v1.AbstractApplicationResource.$anonfun$environmentInfo$1(OneApplicationResource.scala:114)

Does this PR introduce any user-facing change?

No

How was this patch tested?

  • Tested this change on a local instance of SHS

Was this patch authored or co-authored using generative AI tooling?

No

@mridulm
Copy link
Contributor

mridulm commented Aug 7, 2025

Thanks for the bug fix.

Looks like metricsProperties got added in #36462, and for 'older' event files, this would end up becoming null which would have broken it for history server at that time - will setting it to a default value of Nil remove the issue observed ?

Note that Apache Spark does not support 3.4 anymore - so changes specifically to make master work with older/unsupported versions (and their event files), unless it is an ongoing issue, is unlikely to get merged.

+CC @dongjoon-hyun , @LuciferYang as well for thoughts.

@dongjoon-hyun
Copy link
Member

The proposal looks good to me, @thejdeep and @mridulm .

@thejdeep
Copy link
Contributor Author

thejdeep commented Aug 7, 2025

@mridulm Current master is compatible (w.r.t metricsProperties) with older versions of Spark since the KVStore DB is generated correctly. However, current master is incompatible with KVStore's generated with older versions of Spark.

This can be an issue, if a user decides to upgrade their Spark version but does not purge the SHS local store directory.

@thejdeep thejdeep changed the title [SPARK-53158][WEBUI] Redaction of properties should handle null values [SPARK-53158][WEBUI] Missing metricsProperties in KV Store should be handled correctly Aug 7, 2025
…uld default to Nil

 ### What changes were proposed in this pull request?

When environment property maps (e.g. metricsProperties) are null — often due to LevelDBs created by Spark versions that did not have the property, the Utils.redact(...) function throws a NullPointerException during .map or .toArray operations.

 ### Why are the changes needed?

Without this change, the rest API response of /environment throws a 500 due to the server NullPointerException.
The NullPointerException is the following :
```
Caused by: java.lang.NullPointerException: Cannot invoke "scala.collection.Seq.map(scala.Function1, scala.collection.generic.CanBuildFrom)" because "kvs" is
 null
        at org.apache.spark.util.Utils$.redact(Utils.scala:2923)
        at org.apache.spark.util.Utils$.redact(Utils.scala:2878)
        at org.apache.spark.status.api.v1.AbstractApplicationResource.$anonfun$environmentInfo$1(OneApplicationResource.scala:114)
```

 ### Does this PR introduce _any_ user-facing change?

No

 ### How was this patch tested?

- Tested this change on a local instance of SHS

 ### Was this patch authored or co-authored using generative AI tooling?

No
Copy link
Contributor

@mridulm mridulm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test to validate this works ?
As in, json record without the field - and yet gets deserialized with Nil and not null for ApplicationEnvironmentInfo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants