You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var errs []error
for {
// buffered channel avoid goroutine leak
result := make(chan error, 1)
go func() {
l.Printf("retrier: executing work: %s", name)
result <- work()
}()
select {
case res := <-result:
{
if res == nil {
return nil
}
l.Printf("%s: got error: %s", name, res)
errs = append(errs, res)
}
case <-ctx.Done():
{
l.Printf("retrier: %s: timeouted, returning all errors", name)
return append(
errs,
errors.New("retrier timeout"),
)
}
}
// Sometimes we geet an error like: Number of write requests
// for subscription 'x'
// exceeded the limit of '1200' for time interval '01:00:00'.
// Please try again after '5' minutes
// Before trying again lets backoff a little.
time.Sleep(backoff)
}
To prevent Close being called at the same time as a Write I would have to wait all pending work jobs that are running before cancelling the test (and eventually calling tearDown).
The problem is that I do this on purpose exactly to guarantee that if some work goes haywire I guarantee that our teardown function WILL be executed, guaranteeing that resources are ALWAYS cleanedup, even when something locks up forever.
Now I can't think on a better solution then implementing a concurrency safe logger that prevents Write/Read being called concurrently with Close.
There is a discussion about this, and solving this on the os.File don't make sense, but on our particular case it makes sense:
Logs:
The text was updated successfully, but these errors were encountered: