fix: bound scheduler latest status lookup#2278
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
📝 WalkthroughWalkthroughAdds a durable .dagrun.latest pointer with update/retrieval/locking and store integration, refactors shell command construction and exposes test helpers, preallocates env slices and relaxes reuse checks for evaluated empty envs, and updates related tests and benchmarks. ChangesEnvironment Evaluation Optimization
Shell-command construction refactor and tests
Latest Attempt Pointer Persistence
Scheduler catch-up test tweak
Chatbridge monitor tests
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/persis/file/dagrun/latest_attempt.go`:
- Around line 36-78: updateLatestAttemptPointer ignores its ctx; add
cancellation checks so the function stops and releases the lock promptly if the
context is canceled. After successfully acquiring lock (after lock.TryLock
returns nil and before calling latestAttemptInfoFromPointer) check
ctx.Err()/select on ctx.Done and if canceled unlock (use lock.Unlock) and return
ctx.Err(); also check context again immediately before performing the file write
(before json.Marshal or at least before fileutil.WriteFileAtomic) and if
canceled unlock and return ctx.Err(); ensure the existing unlock boolean
semantics (unlock variable and deferred unlock) are preserved so the lock is
always released when returning on context cancellation; touch symbols:
updateLatestAttemptPointer, lock.TryLock, latestAttemptInfoFromPointer,
fileutil.WriteFileAtomic, latestAttemptPointerPath, and candidate/ptr to locate
changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 426c071d-cab0-45f0-be34-2c6aaa559033
📒 Files selected for processing (7)
internal/core/spec/dag.gointernal/core/spec/runtime_env.gointernal/core/spec/runtime_env_external_test.gointernal/persis/file/dagrun/attempt.gointernal/persis/file/dagrun/latest_attempt.gointernal/persis/file/dagrun/latest_attempt_external_test.gointernal/persis/file/dagrun/store.go
|
@codex full review |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
Root cause
The scheduler asks for latest DAG status while planning scheduled runs. On the file backend, latest-attempt lookup could fall back to walking and sorting the current day run directory, so frequent schedules accumulated file traversal, I/O, and cache pressure as data/dag-runs grew.
Validation
Fixes #546
Summary by cubic
Bound the scheduler’s latest-status lookup on the file backend by persisting a validated pointer to the latest attempt, avoiding rescans of large run directories. Also stabilized shell command substitution and scheduler timing tests, skipped no-op status rewrites, reused evaluated empty DAG envs, and hardened notification monitor assertions. Fixes #546.
.dagrun.latestpointer indagrun; update it on attempt writes; respect context cancellation.-NoProfile/-NonInteractive, avoid duplicate-Command.ResolveEnvWithWarnings; minor env slice preallocation.Written for commit 10c9254. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests