-
Notifications
You must be signed in to change notification settings - Fork 816
fix calculation of expected tables and create tables from upcoming schema considering grace period #1976
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 calculation of expected tables and create tables from upcoming schema considering grace period #1976
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.
LGTM
@@ -239,7 +239,8 @@ func (m *TableManager) calculateExpectedTables() []TableDesc { | |||
result := []TableDesc{} | |||
|
|||
for i, config := range m.schemaCfg.Configs { | |||
if config.From.Time.Time().After(mtime.Now()) { | |||
// Consider configs which we are about to hit and requires tables to be created due to grace period | |||
if config.From.Time.Time().After(mtime.Now().Add(m.cfg.CreationGracePeriod)) { |
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.
Note to myself: this looks a safe change to me. We're going to create the new table a bit ahead of time, which is what we want.
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.
Seems legit. One thought about a comment.
pkg/chunk/schema_config.go
Outdated
@@ -424,8 +424,8 @@ func (cfg *PeriodicTableConfig) periodicTables(from, through model.Time, pCfg Pr | |||
nowWeek = now / periodSecs | |||
result = []TableDesc{} | |||
) | |||
// If through ends on 00:00 of the day, don't include the upcoming day | |||
if through.Unix()%secondsInDay == 0 { | |||
// Make sure we don't have an extra table |
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 think this comment is now less explanatory. Could say something like “If interval ends exactly on a period boundary, don’t include the upcoming period”.
…hema considering grace period Signed-off-by: Sandeep Sukhani <[email protected]>
Signed-off-by: Sandeep Sukhani <[email protected]>
Signed-off-by: Sandeep Sukhani <[email protected]>
0ec33b4
to
b5f271e
Compare
What this PR does:
This PR includes following to fixes:
Fix calculation of expected tables:
While calculating periodic tables for a given duration, the end time of the duration was used to find what the last table number would be. To avoid creating an extra table, there was a check whether end duration was ending exactly at end of the day which was causing the whole table to be omitted. Instead of checking against a days duration, this PR uses periodic table duration to check whether we have an extra table.
Create tables from upcoming schema considering grace period:
We skip creating tables for configs whose start time is after
now()
which means tables would not be created until we already are past the start time of config. This can cause writes to fail since tables won't be created already for writing data to it.This PR checks whether the config start time is before
now() + gracePeriod
when creating tables.Which issue(s) this PR fixes:
Fixes: #1920
In #1920, the start time of config was not set to the day when tables would rotate. When the time was just short by grace period before hitting next config, this block started calculating tables for duration from
start-of-active-schema
tostart-of-next-schema
. Since the end was not a multiple of table duration but was a multiple of a days duration, issue 1 above was causing table manager to unexpectedly drop the active table.Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]