Merge pull request #10348 from hashicorp/dnephin/fix-submatview-store-bug

submatview: fix a bug with Store.Get
This commit is contained in:
Daniel Nephin 2021-06-04 12:04:29 -04:00 committed by GitHub
commit 1766aa8a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -118,8 +118,11 @@ func (s *Store) Get(ctx context.Context, req Request) (Result, error) {
}
defer s.releaseEntry(key)
ctx, cancel := context.WithTimeout(ctx, info.Timeout)
defer cancel()
if info.Timeout > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, info.Timeout)
defer cancel()
}
result, err := materializer.getFromView(ctx, info.MinIndex)
// context.DeadlineExceeded is translated to nil to match the timeout

View File

@ -160,7 +160,6 @@ func (r *fakeRequest) CacheInfo() cache.RequestInfo {
Key: key,
Token: "abcd",
Datacenter: "dc1",
Timeout: 4 * time.Second,
MinIndex: r.index,
}
}