fix: pre-filter retry scanner DAG runs at index level (#2261)#2262
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR fixes a memory leak by preventing unnecessary allocation of DAGRun objects when filtering by status and explicitly releasing heap memory in the scheduler loop. The index-level pre-filter skips runs that do not match the requested status, while periodic ChangesMemory Leak Fix: Pre-filter DAG Runs and Release Heap
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 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 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 |
ab2f9b6 to
faa8dbe
Compare
|
LGTM, thank you very much for the improvement! |
Summary
Single fix for the memory leak reported in #546, root-caused in #2261.
The file-based DAG run store's
loadDayRunsfunction createsDAGRunobjects for ALL runs in a day beforeresolveStatusfilters them by status. The day index already contains the status — use it for pre-filtering.Changes
internal/persis/file/dagrun/pagination.go— Pass the status filter toloadDayRuns. When the day index is present and a status filter is active, check each index entry'sStatusbefore callingNewDAGRun. Skip entries whose known status doesn't match the filter.This avoids creating 12,960+
DAGRun+DAGRunStatusobjects per retry-scanner scan for installations with many historical runs (9 DAGs × every minute = 12,960 runs/day in a 24h window).Design Decision: No periodic
FreeOSMemory()We considered adding a periodic
debug.FreeOSMemory()call to the scheduler's cronLoop to return accumulated heap to the OS. Rejected — two reasons:No new imports, no runtime penalty.
Closes #2261
Related: #546