History Server: collect rotated Ray logs before overwrite #5101
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 544 lines diff across 6 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.377
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5101"
general
weight: 0.35
Future-Outlier
Why are these changes needed?
Ray rotates node logs through a limited local backup ring such as
raylet.out.1,.2, etc. Older generations can be overwritten before the History Server collector uploads them, which can lose log history for long-running workloads.This PR adds periodic collection of completed rotated Ray logs for both head and worker collectors.
What does this change?
The collector scans the active Ray session log directory periodically. The interval defaults to 30 seconds and can be configured with:
RAY_COLLECTOR_ROTATED_LOG_SCAN_INTERVALThe interval should be shorter than the time Ray takes to cycle through its configured rotation backups, which depends on
RAY_ROTATION_MAX_BYTES,RAY_ROTATION_BACKUP_COUNTand the log generation rate.The collector also performs an initial scan on startup.
For each scan:
1. Collect the rotated backup paths.
2. Sort them by rotation index, highest first, because that generation is evicted next.
3. For each file, open it, call
fstat, derive its identity, upload synchronously throughStorageWriter.WriteFile, then close it.4. Record the object as uploaded only after a successful write.
5. Prune uploaded-state entries for generations that are no longer present on disk after a complete scan.
The existing collector stop signal is checked between candidates so shutdown collection can handle anything left.
No hard-link staging, persistent rotated-log state or asynchronous upload worker is required.
Object naming
Ray reuses rotation indexes such as
.1and.2, so those indexes are removed from the uploaded object name.The generation identity uses modification time and inode from the opened file descriptor:
<base>.rotated.<time>-<inode><ext>For example:
Putting the modification time first also keeps generations of the same stream ordered chronologically in a plain object listing.
Existing relative log subdirectories are preserved.
Deduplication and retry
The periodic scan, shutdown collection and
prev-logsprocessing use the same deterministic rotated-log naming.A generation already uploaded during the current collector run is skipped. A generation first encountered during shutdown or
prev-logsis uploaded using the same deterministic name rather than the rawxxx.Nfilename.Failed uploads from the periodic active-session scan are not recorded, so a later scan can retry while that generation remains in Ray's local rotation ring.
Collection remains best effort. If Ray removes a generation before a successful scan/upload, that generation cannot be recovered.
History Server behavior
Rotated objects remain available through log listing and explicit filename access.
Canonical
task_id,actor_idandpidresolution continues to select non-rotated worker logs.Rotated
event_.logfiles follow the normal event ingestion behavior.Documentation
The sample collector configs and the in-repo History Server README document the scan interval and its relationship to Ray's rotation settings.
The linked KubeRay History Server user guide is maintained in
ray-project/ray, so that documentation can be updated separately.Related issue number
Closes #4830
Checks
[x] Unit tests
[x] Race detector
[x]
go vet ./...[x]
go build ./...[x]
make test[x] Linux amd64 build
[x] Linux arm64 build
[x] Linux Docker validation
[x] Kind + MinIO manual validation
Manual validation
Validated with Kind, MinIO, Ray 2.52.0 and:
Observed:
211 rotated generations uploaded while only 31 backups remained on disk
zero duplicate rotated objects
zero raw
.Nrotated objects in storagehighest rotation index uploaded first
correct head and worker collection
History Server listing and explicit filename retrieval working
canonical PID resolution continued to select the non-rotated log
zero collector errors