Skip to content
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

Fix NPEs in TypesAccumulator #1363

Merged
merged 1 commit into from
Oct 7, 2024
Merged

Fix NPEs in TypesAccumulator #1363

merged 1 commit into from
Oct 7, 2024

Conversation

istreeter
Copy link
Contributor

We've seen exceptions in spark executors like:

java.lang.NullPointerException: Cannot invoke "scala.collection.mutable.Set.isEmpty()" because the return value of "com.snowplowanalytics.snowplow.rdbloader.transformer.batch.spark.TypesAccumulator.accum()" is null

The error is coming from our Spark Accumulator for accumulating Iglu types. This is similar to an issue previously seen in Spark's own CollectionAccumulator. That issue was fixed in Spark by making the accumulator's internal state non-final, and synchronizing access to the internal state. So here we make the exact same change to our own Accumulator.

It is a rare race condition which is hard to reproduce.

@istreeter
Copy link
Contributor Author

We have another accumulator... the TimestampsAccumulator. But I think that does not need the same fix, because it's internal state is a Option and at runtime a None in scala is just represented by null. And besides, we have never seen a NPE with that accumulator. And Spark core has other accumulators which do not synchronize on every access.

We've seen exceptions in spark executors like:

```
java.lang.NullPointerException: Cannot invoke "scala.collection.mutable.Set.isEmpty()" because the return value of "com.snowplowanalytics.snowplow.rdbloader.transformer.batch.spark.TypesAccumulator.accum()" is null
```

The error is coming from our Spark Accumulator for accumulating Iglu
types. This is similar to [an issue previously seen][1] in Spark's own
`CollectionAccumulator`. That issue [was fixed in Spark][2] by making
the accumulator's internal state non-final, and synchronizing access to
the internal state. So here we make the exact same change to our own
Accumulator.

It is a rare race condition which is hard to reproduce.

[1]: https://issues.apache.org/jira/browse/SPARK-20977
[2]: apache/spark#31540
@spenes spenes merged commit d540e99 into develop Oct 7, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants