-
Notifications
You must be signed in to change notification settings - Fork 820
Don't update lastUpdateTime if TSDB isn't updated. #3727
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
Don't update lastUpdateTime if TSDB isn't updated. #3727
Conversation
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.
Thanks for the fix. The changes LGTM.
db.setLastUpdate(time.Now()) | ||
// If only invalid samples are pushed, don't change "last update", as TSDB was not modified. | ||
if succeededSamplesCount > 0 { | ||
db.setLastUpdate(time.Now()) |
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.
We can avoid time.Now()
using startCommit
.
db.setLastUpdate(time.Now()) | |
db.setLastUpdate(startCommit) |
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.
I don't think we need to avoid time.Now()
here. Furthermore there are cases where commit takes quite a while. We only have bucket up to 10 seconds, but metrics show that we hit it regularly on some ingesters (!), although in practice that should still be good enough.
lastUpdate := db.lastUpdate.Load() | ||
|
||
// Wait until 1 second passes. | ||
test.Poll(t, 1*time.Second, time.Now().Unix()+1, func() interface{} { |
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 not time.Sleep(time.Second)
?
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.
test.Poll
allows us to wait shorter.
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.
Could you also add a CHANGELOG entry, please?
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
What this PR does: This PR modified ingester to not update "lastUpdate" time if push request didn't contain any sample that was appended to TSDB.
Without doing this change, continuous push of bad samples will keep TSDB in memory with unflushed data. If "good" sample arrives much later, all old data will be finally put to block.
With this change, ingester will eventually flush and close such TSDB, and remove local data. After closing, next push of valid or invalid sample will reopen TSDB again (and then later close, if no valid samples arrive), but at least old samples will not be kept in the memory for a long time.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]