Don't do any watch tracking for non-blocking queries.

This commit is contained in:
James Phillips 2017-01-19 11:12:29 -08:00
parent 05735e39a5
commit fefed7c803
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11

View File

@ -464,10 +464,15 @@ RUN_QUERY:
// Run the query. // Run the query.
metrics.IncrCounter([]string{"consul", "rpc", "query"}, 1) metrics.IncrCounter([]string{"consul", "rpc", "query"}, 1)
ws := memdb.NewWatchSet()
err := fn(ws) // We can skip all watch tracking if this isn't a blocking query.
var ws memdb.WatchSet
if queryOpts.MinQueryIndex > 0 {
ws = memdb.NewWatchSet()
}
// Block up to the timeout if we didn't see anything fresh. // Block up to the timeout if we didn't see anything fresh.
err := fn(ws)
if err == nil && queryMeta.Index > 0 && queryMeta.Index <= queryOpts.MinQueryIndex { if err == nil && queryMeta.Index > 0 && queryMeta.Index <= queryOpts.MinQueryIndex {
if expired := ws.Watch(timeout.C); !expired { if expired := ws.Watch(timeout.C); !expired {
goto RUN_QUERY goto RUN_QUERY