mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect: mention command-line flag, which could be used for adjusting query timeouts, in timeout errors
This commit is contained in:
parent
f3b9f8b823
commit
e127173984
@ -101,7 +101,7 @@ func (rss *Results) RunParallel(f func(rs *Result, workerID uint)) error {
|
|||||||
rowsProcessed := 0
|
rowsProcessed := 0
|
||||||
for pts := range workCh {
|
for pts := range workCh {
|
||||||
if time.Until(rss.deadline.Deadline) < 0 {
|
if time.Until(rss.deadline.Deadline) < 0 {
|
||||||
err = fmt.Errorf("timeout exceeded during query execution: %s", rss.deadline.Timeout)
|
err = fmt.Errorf("timeout exceeded during query execution: %s", rss.deadline.String())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err = pts.Unpack(rss.tbf, rs, rss.tr, rss.fetchData, rss.at, maxWorkersCount); err != nil {
|
if err = pts.Unpack(rss.tbf, rs, rss.tr, rss.fetchData, rss.at, maxWorkersCount); err != nil {
|
||||||
@ -1010,7 +1010,7 @@ func (sn *storageNode) execOnConn(rpcName string, f func(bc *handshake.BufferedC
|
|||||||
// since it may be broken.
|
// since it may be broken.
|
||||||
_ = bc.Close()
|
_ = bc.Close()
|
||||||
}
|
}
|
||||||
return fmt.Errorf("cannot execute rpcName=%q on vmstorage %q with timeout %s: %s", rpcName, remoteAddr, deadline.Timeout, err)
|
return fmt.Errorf("cannot execute rpcName=%q on vmstorage %q with timeout %s: %s", rpcName, remoteAddr, deadline.String(), err)
|
||||||
}
|
}
|
||||||
// Return the connection back to the pool, assuming it is healthy.
|
// Return the connection back to the pool, assuming it is healthy.
|
||||||
sn.connPool.Put(bc)
|
sn.connPool.Put(bc)
|
||||||
@ -1406,13 +1406,24 @@ var rsPool sync.Pool
|
|||||||
// Deadline contains deadline with the corresponding timeout for pretty error messages.
|
// Deadline contains deadline with the corresponding timeout for pretty error messages.
|
||||||
type Deadline struct {
|
type Deadline struct {
|
||||||
Deadline time.Time
|
Deadline time.Time
|
||||||
Timeout time.Duration
|
|
||||||
|
timeout time.Duration
|
||||||
|
flagHint string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDeadline returns deadline for the given timeout.
|
// NewDeadline returns deadline for the given timeout.
|
||||||
func NewDeadline(timeout time.Duration) Deadline {
|
//
|
||||||
|
// flagHint must contain a hit for command-line flag, which could be used
|
||||||
|
// in order to increase timeout.
|
||||||
|
func NewDeadline(timeout time.Duration, flagHint string) Deadline {
|
||||||
return Deadline{
|
return Deadline{
|
||||||
Deadline: time.Now().Add(timeout),
|
Deadline: time.Now().Add(timeout),
|
||||||
Timeout: timeout,
|
timeout: timeout,
|
||||||
|
flagHint: flagHint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns human-readable string representation for d.
|
||||||
|
func (d *Deadline) String() string {
|
||||||
|
return fmt.Sprintf("%.3f seconds; the timeout can be adjusted with `%s` command-line flag", d.timeout.Seconds(), d.flagHint)
|
||||||
|
}
|
||||||
|
@ -953,15 +953,15 @@ func getMaxLookback(r *http.Request) (int64, error) {
|
|||||||
|
|
||||||
func getDeadlineForQuery(r *http.Request) netstorage.Deadline {
|
func getDeadlineForQuery(r *http.Request) netstorage.Deadline {
|
||||||
dMax := int64(maxQueryDuration.Seconds() * 1e3)
|
dMax := int64(maxQueryDuration.Seconds() * 1e3)
|
||||||
return getDeadlineWithMaxDuration(r, dMax)
|
return getDeadlineWithMaxDuration(r, dMax, "-search.maxQueryDuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeadlineForExport(r *http.Request) netstorage.Deadline {
|
func getDeadlineForExport(r *http.Request) netstorage.Deadline {
|
||||||
dMax := int64(maxExportDuration.Seconds() * 1e3)
|
dMax := int64(maxExportDuration.Seconds() * 1e3)
|
||||||
return getDeadlineWithMaxDuration(r, dMax)
|
return getDeadlineWithMaxDuration(r, dMax, "-search.maxExportDuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeadlineWithMaxDuration(r *http.Request, dMax int64) netstorage.Deadline {
|
func getDeadlineWithMaxDuration(r *http.Request, dMax int64, flagHint string) netstorage.Deadline {
|
||||||
d, err := getDuration(r, "timeout", 0)
|
d, err := getDuration(r, "timeout", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d = 0
|
d = 0
|
||||||
@ -970,7 +970,7 @@ func getDeadlineWithMaxDuration(r *http.Request, dMax int64) netstorage.Deadline
|
|||||||
d = dMax
|
d = dMax
|
||||||
}
|
}
|
||||||
timeout := time.Duration(d) * time.Millisecond
|
timeout := time.Duration(d) * time.Millisecond
|
||||||
return netstorage.NewDeadline(timeout)
|
return netstorage.NewDeadline(timeout, flagHint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBool(r *http.Request, argKey string) bool {
|
func getBool(r *http.Request, argKey string) bool {
|
||||||
|
@ -31,7 +31,7 @@ func TestExecSuccess(t *testing.T) {
|
|||||||
Start: start,
|
Start: start,
|
||||||
End: end,
|
End: end,
|
||||||
Step: step,
|
Step: step,
|
||||||
Deadline: netstorage.NewDeadline(time.Minute),
|
Deadline: netstorage.NewDeadline(time.Minute, ""),
|
||||||
}
|
}
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
result, err := Exec(ec, q, false)
|
result, err := Exec(ec, q, false)
|
||||||
@ -5243,7 +5243,7 @@ func TestExecError(t *testing.T) {
|
|||||||
Start: 1000,
|
Start: 1000,
|
||||||
End: 2000,
|
End: 2000,
|
||||||
Step: 100,
|
Step: 100,
|
||||||
Deadline: netstorage.NewDeadline(time.Minute),
|
Deadline: netstorage.NewDeadline(time.Minute, ""),
|
||||||
}
|
}
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
rv, err := Exec(ec, q, false)
|
rv, err := Exec(ec, q, false)
|
||||||
|
Loading…
Reference in New Issue
Block a user