Monday, May 20, 2024
HomeGolangSudden choose conduct - Getting Assist

Sudden choose conduct – Getting Assist


I’ve some code that appears like the next
.
.
.
for {
choose {
case sumData := <-incomingChannel:
doSomeWork(sumData)
case <-beatingHeart.C:
doHeartBeatStuff()
case <-ctx.Carried out():
return
}
}

The beatingHeart ticker is ready for two seconds. The code works as anticipated so long as there’s visitors on the incomingChannel. If the system is idle for a couple of hours, the ticker will be seen to not go off for 15-90 seconds, then return to its anticipated each 2 seconds.

Once we use this similar choose sample for a number of goroutines, practically all of them exhibit this conduct at roughly the identical time (inside a second of one another).

Any ideas?

I don’t get it. why the ticker go off?

Both the ticker doesn’t go off each two seconds, or choose just isn’t choosing it up. I don’t know which or find out how to inform. Has anybody seen this conduct earlier than?

I haven’t seen this conduct earlier than. Although most often the place I’m spinning up goroutines to do issues within the background like well being checks / ship queued emails / no matter I actually most likely wouldn’t discover if there was a 15-90 second delay intermittently. It’s attention-grabbing that all the goroutines expertise this similar sample at practically the identical time. Makes me marvel if there’s one thing occurring at the next degree in your server. Like for instance, is it attainable that you’re operating this as a service, one thing panics and goes horribly awry, and the service restarts itself?

If I had been you, I’d create a demo app to breed what you might be seeing and create a ticket on the official go repo.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments