-
Notifications
You must be signed in to change notification settings - Fork 816
TableClient for each PeriodConfig in Schema #1446
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
Conversation
Signed-off-by: Ganesh Vernekar <[email protected]>
ba86f9c
to
9a86dc8
Compare
return err | ||
} | ||
for i, client := range m.clients { | ||
toCreate, toCheckThroughput, toDelete, err := m.partitionTables(ctx, client, expected) |
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 doesn't seem right. This would mean that every single client would create a bunch of random tables (ones that belong to other clients).
Can we pass config
to calculateExpectedTables()
and then use that for each of the clients?
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 was thinking the same. But it is the same behavior before apparently. calculateExpectedTables
parses all the configs, and creates/updates/deletes from the last client. Here I was only deleting from old client, but left the behavior of the last client unchanged.
Do you want me to change it to per client for calculateExpectedTables
?
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.
But the delete calls will fail, as they are trying to delete tables that don't exist. Yeah, changing calculateExpectedTables
makes sense.
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.
Tests failed for the change described. While I am still digging into the test failure, from past implementation my understanding is that i th
client uses all config from the starting till the i th
config to create tables.
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 changed the implementation to use 0,1,...,i'th
config for the i'th
client. Tests pass for that. It that the expected behaviour then?
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.
Doesn't sound right. Why wouldn't the i'th client just use the i'th config?
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.
What you said sounds right. Apparently the old code used all the configs for the client. I will update the tests then.
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.
Now I see why all the configs were parsed in the old code
cortex/pkg/chunk/table_manager.go
Lines 244 to 255 in 53438df
if i+1 < len(m.schemaCfg.Configs) { | |
var ( | |
endTime = m.schemaCfg.Configs[i+1].From.Unix() | |
gracePeriodSecs = int64(m.cfg.CreationGracePeriod / time.Second) | |
maxChunkAgeSecs = int64(m.maxChunkAge / time.Second) | |
now = mtime.Now().Unix() | |
) | |
if now >= endTime+gracePeriodSecs+maxChunkAgeSecs { | |
isActive = false | |
} | |
} |
The old configs are parsed and checked for grace period w.r.t new configs. Also provisions read/write accordingly if the config is active/inactive. I guess we would need parsing the old configs if we want to delete the tables from the client if tables were created because of the grace period. So 0,1,...,i'th
configs are only parsed inside calculateExpectedTables
for the i'th
client, and not necessarily used.
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 we make a rule that grace period only applies to the latest config?
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.
Done.
Signed-off-by: Ganesh Vernekar <[email protected]>
Instead of taking only i'th config for the i'th client, take 0,1,...,i'th PeriodConfig for i'th client in calculateExpectedTables. Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
@gouthamve @bboreham Since you two had looked at this PR previously, can you please look at it again? I'm taking a scan through old PRs to clear out older items laying about. |
if lastClient { | ||
return err | ||
} | ||
level.Error(util.Logger).Log("msg", "error in deleting tables from TableClient") |
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 log output states there was an error, but offers no context or the error itself. Can you add more details to this line in order to make it useful for troubleshooting?
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.
👍 It would be good to print the error in this log statement
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, I think things are good as is but I did have one suggestion above. I don't think it's mandatory for approval. Also please add an error to the log statement @khaines mentioned above.
tableClient, err := storage.NewTableClient(lastConfig.IndexType, cfg.Storage) | ||
if err != nil { | ||
return err | ||
var tableClients []chunk.TableClient |
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.
Is there any reason we can't generate the table and bucket clients inside the NewTableManager function? Instead of instantiating the clients and passing them as a parameter would could just pass the storage config as a parameter. I think the way things are now is probably fine. However, the columnar relationship between the schema cfg and clients makes me think it might be better to encapsulate this logic inside the function. The comment I'm referring to:
// The i'th TableClient in 'tableClients' should correspond to the i'th PeriodConfig in schemaCfg.Config.
// The TableClient for the last client should not be nil.
func NewTableManager(cfg TableManagerConfig, schemaCfg SchemaConfig, maxChunkAge time.Duration, tableClients []TableClient, objectClient BucketClient) (*TableManager, error) {objectClient BucketClient) (*TableManager, error) {
lastClient := i == len(m.clients)-1 | ||
expected := m.calculateExpectedTables(i) | ||
if lastClient { | ||
level.Info(util.Logger).Log("msg", "synching tables", "num_expected_tables", len(expected), "expected_tables", len(expected)) |
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.
What is the difference between num_expected_tables
and expected_tables
in these two log statements?
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.
Ah I already opened a PR to fix it upstream before looking at this comment #1754, they are the same. Noticed this log when running Loki.
Will fix it here too.
startIdx := idx | ||
if idx == len(m.schemaCfg.Configs)-1 { | ||
// For the last client, collect tables from all the configs. | ||
startIdx = 0 |
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 are we collecting all of the tables for the final config? Won't this lead to tables being created that will never be used?
I took a second look and had a few questions
@gouthamve @jtlisi @bboreham What's the state of this PR? Is it something we wanna put some effort to reach a mergeable state, or should we close it? |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
Closing this to let someone else take it up. I don't plan to work on this further at the moment. |
Attempt to fix #1382
This PR creates a TableClient for all the past configs and deletes tables from all the clients in
SyncTables
.