-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix store query bug when running loki in single binary mode with boltdb-shipper #2655
fix store query bug when running loki in single binary mode with boltdb-shipper #2655
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2655 +/- ##
==========================================
+ Coverage 61.22% 61.46% +0.24%
==========================================
Files 172 172
Lines 13360 13380 +20
==========================================
+ Hits 8179 8224 +45
+ Misses 4431 4410 -21
+ Partials 750 746 -4
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
// query ingester for whole duration. | ||
if ingesterMLB == -1 { | ||
i := &interval{ | ||
start: queryStart, | ||
end: queryEnd, | ||
} | ||
|
||
if limitQueryInterval { | ||
// query only ingesters. | ||
return i, nil | ||
} | ||
|
||
// query both stores and ingesters without limiting the query interval. | ||
return i, i | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why query ingester for whole duration ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to support the rare usecase where you run Loki with multiple single binaries and each of them storing the data on local filesystem without any sharing.
if !limitQueryInterval { | ||
i := &interval{ | ||
start: queryStart, | ||
end: queryEnd, | ||
} | ||
return i, i | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The microservices deployment mode with object store will run here no matter if there is an overlap.
ingester:
query_store_max_look_back_period: 0
querier:
query_ingesters_within: 2h
This case will also query ingester for whole duration.
What this PR does / why we need it:
When running loki with boltdb-shipper in single binary mode and doing queries not touching the recent data I found that store was not being queried. The problem appears to be here which considers end time of query instead of
time.Now()
while calculatingadjustedEnd
of query. If you do a query for yesterday with 1h interval andIngesterQueryStoreMaxLookback
is set to2h
then theadjustedEnd
would be set to older value than start time of query hence the condition here would be true and result in not querying the store.I have refactored the code to do all the calculations in a separate function which has following properties:
IngesterQueryStoreMaxLookback
would take precedence overQueryIngestersWithin
config.IngesterQueryStoreMaxLookback
would do separate non overlapping queries to stores and ingesters whileQueryIngestersWithin
would do same queries to both which is same as how it was before.Checklist