Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

codesome
Copy link
Contributor

@codesome codesome commented Jun 5, 2019

Attempt to fix #1382

This PR creates a TableClient for all the past configs and deletes tables from all the clients in SyncTables.

@codesome codesome force-pushed the multiple-table-client branch from ba86f9c to 9a86dc8 Compare June 5, 2019 17:46
@codesome codesome marked this pull request as ready for review June 7, 2019 08:58
return err
}
for i, client := range m.clients {
toCreate, toCheckThroughput, toDelete, err := m.partitionTables(ctx, client, expected)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Ganesh Vernekar added 3 commits June 7, 2019 22:33
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]>
@khaines
Copy link
Contributor

khaines commented Oct 21, 2019

@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")
Copy link
Contributor

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?

Copy link
Contributor

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

@gouthamve gouthamve requested a review from jtlisi October 23, 2019 15:53
jtlisi
jtlisi previously approved these changes Oct 23, 2019
Copy link
Contributor

@jtlisi jtlisi left a 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
Copy link
Contributor

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))
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

@jtlisi jtlisi Oct 23, 2019

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?

@jtlisi jtlisi dismissed their stale review October 23, 2019 20:50

I took a second look and had a few questions

@pracucci
Copy link
Contributor

pracucci commented Feb 3, 2020

@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?

@stale
Copy link

stale bot commented Apr 3, 2020

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.

@stale stale bot added the stale label Apr 3, 2020
@pracucci pracucci added keepalive Skipped by stale bot and removed stale labels Apr 3, 2020
@codesome
Copy link
Contributor Author

Closing this to let someone else take it up. I don't plan to work on this further at the moment.

@codesome codesome closed this Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keepalive Skipped by stale bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retention with multiple store configs
6 participants