[SPARK-59747][CORE][4.0] Don't retry compaction of rolled event log files with malformed input #59620
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 418 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #59620"
general
weight: 0.35
sarutak
What changes were proposed in this pull request?
Backport #58996 to
branch-4.0.In
FsHistoryProvider.compact(), catchCharacterCodingExceptionthrown while compacting rolled event log files, log it at WARN, and still recordlastEvaluatedForCompactionfor the current index.EventLogFileCompactor.initializeBuildersalso logs a WARN naming the malformed event log file before rethrowing the decoding exception.The conflict resolution retains this branch's existing single
fileCompactor. The test aliases NIOFilesasJavaFilesto preserve existing GuavaFilescalls.Why are the changes needed?
When the rolled event log files that are eligible for compaction contain bytes that are not valid UTF-8,
EventLogFileCompactorfails with aMalformedInputExceptionwhile replaying them to initialize the event filter builders.compact()only recordslastEvaluatedForCompactionafter compaction succeeds, and the exception reaches the generic handler, which logs it at ERROR.The listing replay stops early, so it never reaches the malformed bytes and the application keeps being listed. Each time the last (non-compacted) event log file grows, the log is reprocessed and compaction of the same unchanged rolled files is tried again. For a long-running application this logs a full stack trace at ERROR on every scan until a new event log file is rolled. Rolled files are no longer modified, so the retry can never succeed.
With this change, compaction for that index is skipped, and it is only tried again once a new event log file is rolled. Other failures are handled as before.
Does this PR introduce _any_ user-facing change?
Yes, but only in History Server logs. When compaction fails because the event log files contain malformed input, the History Server logs a WARN once per rolled event log index instead of an ERROR on every scan. An additional WARN identifies the path of the malformed event log file, alongside the WARN for the application directory. The application listing and replay are unchanged, and the event log files are left uncompacted as before.
How was this patch tested?
Added a new test to
FsHistoryProviderSuite. It writes a rolled event log file with a malformed UTF-8 sequence after the events used for listing, then checks that the application is still listed, no compact file is created,lastEvaluatedForCompactionis recorded, and a WARN names the malformed file.Passed locally with Java 21 on the
branch-4.0backport:Both malformed-input regression variants passed (2 tests), including the WARN naming the malformed file. All 12 compactor tests passed, including the SPARK-60110 incomplete-replay coverage. Both style checks passed with zero errors/warnings;
git diff --checkalso passed. LevelDB-backed variants were not run on Apple Silicon.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5) for the original patch; OpenAI Codex (GPT-5) for the backport.