Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

errors like "invalid request. to must > from" #912

Closed
Dieterbe opened this issue May 15, 2018 · 1 comment
Closed

errors like "invalid request. to must > from" #912

Dieterbe opened this issue May 15, 2018 · 1 comment

Comments

@Dieterbe
Copy link
Contributor

Dieterbe commented May 15, 2018

thanks to jaeger I see (trace 6c3a75072bd1fef1, a0e316731c4c65):
HTTP POST getdata ->
getTargetsLocal with these properties:

key "57208.4539279021e2c5b7a218182593c64f38"
target	foo
pattern	foo
from	1526414053
to	1526414113
span	59
mdp	0
rawInterval	120
cons	"AverageConsolidator"
consReq	"NoneConsolidator"
schemaId	1
aggId	0
archive	0
archInterval	120
TTL	1296000
outInterval	120
aggNum	1
error	true

--> getSeriesAggMetrics

what I think happens:
getTargetsLocal calls
getTarget. readRollup false, normalize false
calls s.getSeriesFixed with consolidation.None
calls newRequestContext, which does this:

        if consolidator == consolidation.None {
                rc.From = prevBoundary(req.From, req.ArchInterval) + 1
                rc.To = prevBoundary(req.To, req.ArchInterval) + 1

and:

func prevBoundary(ts uint32, span uint32) uint32 {
	return ts - ((ts-1)%span + 1)
}

func main() {
	fmt.Println(prevBoundary(1526414053, 120) + 1)
	fmt.Println(prevBoundary(1526414113, 120) + 1)
}
1526414041
1526414041

calls s.getSeries
calls getSeriesAggMetrics
calls metric.Get
calls AggMetric.Get
which triggers:

        if from >= to {
                panic("invalid request. to must > from")                                                                                                                                       
        } 
@Dieterbe Dieterbe added this to the 0.9.1 milestone May 16, 2018
@Dieterbe
Copy link
Contributor Author

Dieterbe commented May 17, 2018

I can reproduce like so:
this patch for more info:

@@ -659,9 +667,14 @@ func newRequestContext(ctx context.Context, req *models.Req, consolidator consol
        // `from`   1..60 needs data    1..60   -> always adjust `from` to previous boundary+1 (here 1)
        // `to`  181..240 needs data 121..180   -> always adjust `to`   to previous boundary+1 (here 181)
 
+       fmt.Println("Consol is", consolidator)
+
        if consolidator == consolidation.None {
+               fmt.Println("consol None so:")
                rc.From = prevBoundary(req.From, req.ArchInterval) + 1
                rc.To = prevBoundary(req.To, req.ArchInterval) + 1
+               fmt.Println("from", req.From, "->", rc.From)
+               fmt.Println("to  ", req.To, "->", rc.To)
                rc.AMKey = schema.AMKey{MKey: req.MKey}
        } else {
                rc.From = req.From
./launch.sh docker-dev-custom-cfg-kafka

fakemetrics feed --period 120s --flush 120s --gnet-addr http://localhost:9000/metrics --gnet-key not_very_secret_key --mpo 120 --orgs 1
curl http://localhost:6060/render\?target\=some.id.of.a.metric.99\*\&from\=-220s\&until\=-200s\&format\=json | jsonpp; date +%s
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    31  100    31    0     0  15500      0 --:--:-- --:--:-- --:--:-- 15500
Expecting value: line 1 column 1 (char 0)
1526554981
metrictank_1    | [Macaron] 2018-05-17 11:03:01: Started GET /render?target=some.id.of.a.metric.99*&from=-220s&until=-200s&format=json for 172.19.0.1
metrictank_1    | Consol is NoneConsolidator
metrictank_1    | consol None so:
metrictank_1    | from 1526554762 -> 1526554681
metrictank_1    | to   1526554782 -> 1526554681
metrictank_1    | 2018/05/17 11:03:01 [graphite.go:771 executePlan()] [E] HTTP Render invalid request. to must > from
metrictank_1    | [Macaron] 2018-05-17 11:03:01: Completed /render?target=some.id.of.a.metric.99*&from=-220s&until=-200s&format=json 500 Internal Server Error in 1.493176ms

Dieterbe added a commit that referenced this issue May 17, 2018
if interval is, say 120s
then you can expect points with these timestamps:
120
240
360
...

previously, if you issued a render request such as to=300,until=330
on a raw archive (which still needs quantizing so we do some tricks)
those tricks would result in bad request errors.
Now we handle them as they should: return [].

fix #912
Dieterbe added a commit that referenced this issue May 17, 2018
if interval is, say 120s
then you can expect points with these timestamps:
120
240
360
...

previously, if you issued a render request such as to=300,until=330
on a raw archive (which still needs quantizing so we do some tricks)
those tricks would result in bad request errors.
Now we handle them as they should: return [].

fix #912
Dieterbe added a commit that referenced this issue May 18, 2018
if interval is, say 120s
then you can expect points with these timestamps:
120
240
360
...

previously, if you issued a render request such as to=300,until=330
on a raw archive (which still needs quantizing so we do some tricks)
those tricks would result in bad request errors.
Now we handle them as they should: return [].

fix #912
Dieterbe added a commit that referenced this issue May 18, 2018
if interval is, say 120s
then you can expect points with these timestamps:
120
240
360
...

previously, if you issued a render request such as to=300,until=330
on a raw archive (which still needs quantizing so we do some tricks)
those tricks would result in bad request errors.
Now we handle them as they should: return [].

fix #912
@Dieterbe Dieterbe modified the milestones: 1.1, 0.10.0 Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant