vladhlinsky opened a new pull request #30845:
URL: https://github.com/apache/spark/pull/30845
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR:
https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g.,
'[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a
faster review.
7. If you want to add a new configuration, please read the guideline first
for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section
is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster
reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class
hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other
DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Mark SHS event log entries that were `processing` at the beginning of the
`checkForLogs` run as not stale and check for this mark before deleting an
event log. This fixes the issue when a particular job was displayed in the SHS
and disappeared after some time, but then, in several minutes showed up again.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
The issue is caused by
[SPARK-29043](https://issues.apache.org/jira/browse/SPARK-29043), which is
designated to improve the concurrent performance of the History Server. The
[change](https://github.com/apache/spark/pull/25797/files#) breaks the ["app
deletion"
logic](https://github.com/apache/spark/pull/25797/files#diff-128a6af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R563)
because of missing proper synchronization for `processing` event log entries.
Since SHS now [filters
out](https://github.com/apache/spark/pull/25797/files#diff-128a6af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R462)
all `processing` event log entries, such entries do not have a chance to be
[updated with the new
`lastProcessed`](https://github.com/apache/spark/pull/25797/files#diff-128a6af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R472)
time and thus any entity that completes processing right after
[filtering](https://github.com/apache/spark/pull/25797/files#diff-128a6
af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R462) and before
[the check for stale
entities](https://github.com/apache/spark/pull/25797/files#diff-128a6af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R560)
will be identified as stale and will be deleted from the UI until the next
`checkForLogs` run. This is because [updated `lastProcessed` time is used as
criteria](https://github.com/apache/spark/pull/25797/files#diff-128a6af0d78f4a6180774faedb335d6168dfc4defff58f5aa3021fc1bd767bc0R557),
and event log entries that missed to be updated with a new time, will match
that criteria.
The issue can be reproduced by generating a big number of event logs and
uploading them to the SHS event log directory on S3. Essentially, around
236(26.7 MB) copies of an event log directory were created using
[shs-monitor](https://github.com/vladhlinsky/shs-monitor/tree/spark-master)
script. Strange behavior of SHS counting the total number of applications was
noticed - at first, the number was increasing as expected, but with the next
page refresh, the total number of applications decreased. No errors were logged
by SHS.
58 entities are displayed at `17:35:35`:

25 entities are displayed at `17:36:40`:

### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as
the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes
- provide the console output, description and/or an example to show the
behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to
the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes, SHS users won't face the behavior when the number of displayed
applications decreases periodically.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some
test cases that check the changes thoroughly including negative and positive
cases if possible.
If it was tested in a way different from regular unit tests, please clarify
how you tested step by step, ideally copy and paste-able, so that other
reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why
it was difficult to add.
-->
Tested using
[shs-monitor](https://github.com/vladhlinsky/shs-monitor/tree/spark-master)
script:
* Build SHS with the proposed change
* Download Hadoop AWS and AWS Java SDK
* Prepare S3 bucket and user for programmatic access, grant required roles
to the user. Get access key and secret key
* Configure SHS to read event logs from S3
* Start
[monitor](https://github.com/vladhlinsky/shs-monitor/blob/spark-master/monitor.sh)
script to query SHS API
* Run 5
[producers](https://github.com/vladhlinsky/shs-monitor/blob/spark-master/producer.sh)
for ~5 mins, create 125(14.2 MB) event log directory copies
* Wait for SHS to load all the applications
* Verify that the number of loaded applications increases continuously over
time
For more details, please refer to the
[shs-monitor](https://github.com/vladhlinsky/shs-monitor/tree/spark-master)
repository.
> This version of the reproduction uses event log directories instead of
single files, since recent optimization
> [SPARK-33790](https://issues.apache.org/jira/browse/SPARK-33790) makes it
hard to reproduce the issue with single
> event log files.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]