app/vmstorage: improve error logging when the request times out

This commit is contained in:
Aliaksandr Valialkin 2020-08-10 13:17:12 +03:00
parent 455bf50a91
commit f3d33e23c9
3 changed files with 7 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package netstorage
import (
"container/heap"
"errors"
"flag"
"fmt"
"runtime"
@ -618,6 +619,9 @@ func ProcessSearchQuery(sq *storage.SearchQuery, fetchData bool, deadline Deadli
}
}
if err := sr.Error(); err != nil {
if errors.Is(err, storage.ErrDeadlineExceeded) {
return nil, fmt.Errorf("timeout exceeded during the query: %s", deadline.String())
}
return nil, fmt.Errorf("search error after reading %d data blocks: %w", blocksRead, err)
}

View file

@ -335,7 +335,7 @@ func (sq *SearchQuery) Unmarshal(src []byte) ([]byte, error) {
func checkSearchDeadlineAndPace(deadline uint64) error {
if fasttime.UnixTimestamp() > deadline {
return errDeadlineExceeded
return ErrDeadlineExceeded
}
storagepacelimiter.Search.WaitIfNeeded()
return nil

View file

@ -887,7 +887,8 @@ func (s *Storage) prefetchMetricNames(tsids []TSID, deadline uint64) error {
return nil
}
var errDeadlineExceeded = fmt.Errorf("deadline exceeded")
// ErrDeadlineExceeded is returned when the request times out.
var ErrDeadlineExceeded = fmt.Errorf("deadline exceeded")
// DeleteMetrics deletes all the metrics matching the given tfss.
//