@@ -177,15 +177,11 @@ func TestSchedulerConcurrentOperations(t *testing.T) {
177177 scheduler := NewScheduler (& TestLogger {})
178178 scheduler .SetMaxConcurrentJobs (5 )
179179
180- // go-cron has internal race conditions when AddJob is called concurrently
181- // while the scheduler is running. We pre-add jobs before starting,
182- // then only test concurrent read/update operations which are safe.
183180 // Reduced worker count to avoid CI timeouts with race detector
184181 const numWorkers = 5
185182 const jobsPerWorker = 3
186183
187- // Pre-add all jobs BEFORE starting the scheduler to avoid race conditions
188- // in go-cron's internal map access during concurrent AddJob calls
184+ // Pre-add jobs before starting the scheduler
189185 for worker := 0 ; worker < numWorkers ; worker ++ {
190186 for jobIdx := 0 ; jobIdx < jobsPerWorker ; jobIdx ++ {
191187 jobName := fmt .Sprintf ("worker%d-job%d" , worker , jobIdx )
@@ -200,6 +196,7 @@ func TestSchedulerConcurrentOperations(t *testing.T) {
200196 if err := scheduler .Start (); err != nil {
201197 t .Fatalf ("Failed to start scheduler: %v" , err )
202198 }
199+ defer scheduler .Stop ()
203200
204201 var wg sync.WaitGroup
205202 wg .Add (numWorkers )
@@ -244,15 +241,10 @@ func TestSchedulerConcurrentOperations(t *testing.T) {
244241 t .Error ("Scheduler should still be running after concurrent operations" )
245242 }
246243
247- // Stop scheduler before adding new jobs to avoid race conditions in go-cron
248- // Note: In our testing, go-cron exhibits race conditions when AddJob is called while running
249- // See: https://github.com/netresearch/go-cron/issues/262
250- scheduler .Stop ()
251-
252- // Test basic functionality still works (add a new job after stress test)
244+ // Test adding a new job while scheduler is running (go-cron v0.7.1 fixed race conditions)
253245 testJob := NewErrorJob ("final-test" , "@daily" )
254246 if err := scheduler .AddJob (testJob ); err != nil {
255- t .Errorf ("Scheduler should still accept jobs after stress test : %v" , err )
247+ t .Errorf ("Scheduler should accept jobs while running : %v" , err )
256248 }
257249}
258250
0 commit comments