Compare commits

...
Author SHA1 Message Date
chrislusf e79138f597 wdclient: reuse isCanceledErr for the elapsed-deadline check 2026-10-28 00:43:15 -07:00
chrislusf 138f356c5d wdclient: cover a lapsed caller deadline that Err() has not observed yet 2026-10-28 00:42:06 -07:00
chrislusf c936959aaf wdclient: reinterpret only deadline errors against an elapsed caller deadline 2026-10-28 00:32:23 -07:00
chrislusf a70f001e26 wdclient: treat an elapsed caller deadline as caller-gave-up on lookup errors
gRPC can surface its own DeadlineExceeded a tick before ctx.Err() becomes
visible, so a lookup that died on the caller's deadline was sporadically
recorded as a filer failure (seen in the linux/386 job).
2026-10-28 00:24:16 -07:00
2 changed files with 27 additions and 2 deletions

No files matched your search

+10 -2
View File
@@ -788,8 +788,16 @@ func (p *filerVolumeProvider) LookupVolumeIds(ctx context.Context, volumeIds []s
}()
if err != nil {
// a caller that gave up says nothing about this filer
if ctxErr := ctx.Err(); ctxErr != nil {
// a caller that gave up says nothing about this filer; gRPC can
// surface its own DeadlineExceeded a tick before ctx.Err()
// becomes visible, so reinterpret only cancellation errors this way
ctxErr := ctx.Err()
if ctxErr == nil && isCanceledErr(err) {
if dl, ok := ctx.Deadline(); ok && !dl.After(time.Now()) {
ctxErr = context.DeadlineExceeded
}
}
if ctxErr != nil {
if lastErr != nil {
return nil, fmt.Errorf("%w (earlier filer error: %v)", ctxErr, lastErr)
}
+17
View File
@@ -309,6 +309,14 @@ func startStallingFiler(t *testing.T) pb.ServerAddress {
return pb.ServerAddress(fmt.Sprintf("127.0.0.1:0.%s", port))
}
// lapsedDeadlineCtx mimics the moment after a caller's deadline has passed but
// before the runtime marks the context done.
type lapsedDeadlineCtx struct{ context.Context }
func (lapsedDeadlineCtx) Deadline() (time.Time, bool) { return time.Now().Add(-time.Second), true }
func (lapsedDeadlineCtx) Done() <-chan struct{} { return nil }
func (lapsedDeadlineCtx) Err() error { return nil }
// A caller giving up must not count as a filer failure, the filer's own timeout must.
func TestLookupVolumeIdsCountsOnlyFilerFailures(t *testing.T) {
tests := []struct {
@@ -338,6 +346,15 @@ func TestLookupVolumeIdsCountsOnlyFilerFailures(t *testing.T) {
wantErr: context.DeadlineExceeded,
wantFailures: 0,
},
{
name: "caller deadline already elapsed",
callerCtx: func() (context.Context, context.CancelFunc) {
return lapsedDeadlineCtx{context.Background()}, func() {}
},
grpcTimeout: 5 * time.Second,
wantErr: context.DeadlineExceeded,
wantFailures: 0,
},
{
name: "filer timeout",
callerCtx: func() (context.Context, context.CancelFunc) {