← Back to Pull requests

History Server: collect rotated Ray logs before overwrite #5101

Closed
unknown closed this pull request without merging on Sep 11, 2026 21:52 UTC
View on GitHub
unknown unknown commented on Aug 07, 2026 04:04 UTC
Author

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_INTERVAL

The 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_COUNT and 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 through StorageWriter.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 .1 and .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:

worker-abc123-01000000-123.out.1
-> worker-abc123-01000000-123.rotated.1788815931323829009-888699.out

raylet.out.2
-> raylet.rotated.1788816021374077009-889822.out

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-logs processing 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-logs is uploaded using the same deterministic name rather than the raw xxx.N filename.

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_id and pid resolution continues to select non-rotated worker logs.

Rotated event_.log files 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:

RAY_ROTATION_MAX_BYTES=65536
RAY_ROTATION_BACKUP_COUNT=5
RAY_COLLECTOR_ROTATED_LOG_SCAN_INTERVAL=5s

Observed:

211 rotated generations uploaded while only 31 backups remained on disk
zero duplicate rotated objects
zero raw .N rotated objects in storage
highest 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

  • zero Ray or collector container restarts
  • Diff: 544 lines (+408 / -136) across 6 files Reviewer: Future-Outlier Review duration: 51468m
    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
    0.48
    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.377
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5101"
    general weight: 0.35
    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: 48% (MEDIUM) · Higher = larger blast radius
    48%
    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: 20.8% · Safe to merge
    20.8%