Skip to content

fix: resolve cron scheduler goroutine leak and modernize usage#831

Open
CybotTM wants to merge 2 commits intoSeagate:mainfrom
CybotTM:fix/cron-scheduler-improvements
Open

fix: resolve cron scheduler goroutine leak and modernize usage#831
CybotTM wants to merge 2 commits intoSeagate:mainfrom
CybotTM:fix/cron-scheduler-improvements

Conversation

@CybotTM
Copy link

@CybotTM CybotTM commented Feb 12, 2026

Summary

  • Fix goroutine leak: store *cron.Cron instance and call Stop() during shutdown
  • Replace hand-rolled validation: use go-cron's built-in ValidateSpec() instead of custom isValidCronExpression()
  • Upgrade go-cron to v0.11.0

Context

Found during netresearch/go-cron dependent analysis. The cron scheduler was created in SetupScheduler() but never stored as a struct field, making it impossible to stop — causing a goroutine leak for the lifetime of the process.

Changes

File Change
component/azstorage/azautolog.go Store *cron.Cron as struct field, call Stop() in Stop() method
component/azstorage/azautolog.go Replace isValidCronExpression() with cron.ValidateSpec()
go.mod / go.sum Upgrade go-cron to v0.11.0

Test plan

  • Verify Stop() is called during component shutdown
  • Verify cron expression validation still works
  • Verify scheduled uploads still fire correctly

…duler

- Store cron.Cron instance so it can be stopped during FileCache shutdown
- Initialize stopAsyncUpload channel (was nil, making select cases dead code)
- Call cron.Stop() in FileCache.Stop() and wait for graceful shutdown
- Replace hand-rolled Schedule.Next() loop with ScheduleWithPrev.Prev()
  and WithRunImmediately() for cleaner active-window detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant