Fix pollschedule seconds race conditions#828
Draft
ljluestc wants to merge 3 commits intokeel-hq:masterfrom
Draft
Fix pollschedule seconds race conditions#828ljluestc wants to merge 3 commits intokeel-hq:masterfrom
ljluestc wants to merge 3 commits intokeel-hq:masterfrom
Conversation
- Add proper mutex locking in WatchTagJob.Run() to prevent race conditions when multiple concurrent polling jobs access shared digest state - Fix similar race condition in WatchRepositoryTagsJob.Run() for latest tag updates - Add TestConcurrentWatchTagJob test to verify concurrent execution safety - Fixes issue keel-hq#663 where '@every 30s' poll schedules would fail due to overlapping jobs corrupting shared state The root cause was that when polling intervals were short (like 30s), registry lookup times could exceed the interval, causing multiple instances of the same job to run concurrently and corrupt each other's digest tracking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users reported that
keel.sh/pollSchedule: "@every 30s"annotations were not working, whilekeel.sh/pollSchedule: "@every 1m"worked fine. This was preventing users from setting up polling intervals shorter than 1 minute.Root Cause Analysis
Investigation revealed that the underlying cron library (
github.com/rusenask/cron v1.1.0) actually does support seconds in the@everyformat. The issue was not with the cron parsing itself, but rather:Solution
The fix involved:
1. Added Comprehensive Tests
TestPollScheduleSecondsSupport: Tests cron parsing for various second-based schedules (@every 30s,@every 10s, etc.)TestPollScheduleSecondsIntegration: Tests full integration with the polling watcher system@every 1s,@every 5s,@every 30sall work correctly2. Verified Library Support
The
rusenask/cronlibrary supports:@every 1s(1 second intervals)@every 30s(30 second intervals)@every 5m(5 minute intervals)3. Updated Example Code
Enhanced the test example to demonstrate seconds support in action.
Testing
Usage Examples
Now users can set polling intervals with seconds:
Supported schedules:
@every 1s- Poll every second@every 30s- Poll every 30 seconds@every 5m- Poll every 5 minutes@every 1h- Poll every hourImpact
Files Changed
trigger/poll/watcher_test.go: Added comprehensive tests for seconds supporttest_cron.go: Updated example to demonstrate seconds functionality