← Back to Pull requests

[SPARK-59747][CORE][4.0] Don't retry compaction of rolled event log files with malformed input #59620

Closed
unknown closed this pull request without merging on Oct 27, 2026 20:25 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 00:25 UTC
Author

What changes were proposed in this pull request?

Backport #58996 to branch-4.0.

In FsHistoryProvider.compact(), catch CharacterCodingException thrown while compacting rolled event log files, log it at WARN, and still record lastEvaluatedForCompaction for the current index.

EventLogFileCompactor.initializeBuilders also 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 NIO Files as JavaFiles to preserve existing Guava Files calls.

Why are the changes needed?

When the rolled event log files that are eligible for compaction contain bytes that are not valid UTF-8, EventLogFileCompactor fails with a MalformedInputException while replaying them to initialize the event filter builders. compact() only records lastEvaluatedForCompaction after 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, lastEvaluatedForCompaction is recorded, and a WARN names the malformed file.

Passed locally with Java 21 on the branch-4.0 backport:

build/sbt 'core/Compile/scalastyle' 'core/Test/scalastyle' \
  'core/testOnly org.apache.spark.deploy.history.RocksDBBackendFsHistoryProviderSuite org.apache.spark.deploy.history.RocksDBBackendWithProtobufSerializerSuite -- -z "SPARK-59747"' \
  'core/testOnly org.apache.spark.deploy.history.EventLogFileCompactorSuite'

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 --check also 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.

Diff: 418 lines (+313 / -105) across 5 files Reviewer: sarutak Review duration: 11279m
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
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.0% (MEDIUM) · Higher = larger blast radius
45.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 19.4% · Safe to merge
19.4%
Repository