Skip to content

Conversation

@dcapwell
Copy link
Contributor

No description provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulled from https://issues.apache.org/jira/browse/CASSANDRA-16213, was going to add them there but need them in this patch as well, so copy/pasted from there (but added docs for the ones missing)

Copy link
Contributor

Choose a reason for hiding this comment

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

The get with overrideDefaultValue methods are not used. Not a big problem if the other patch referenced is to be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to all caps so its more clear this is global and not local to the table; seems that this naming convention caused all to be confused with local table names rather than global metrics, so switch to java naming convention to help to prevent this next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did this in https://issues.apache.org/jira/browse/CASSANDRA-16213 as its useful for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a regressions... when not using gossip we didn't register the distributed tables, and we tried to force trace regardless...

right before we gossip tokens around we call this method, so adding it here makes sure the distributed tables work with and without gossip.

Copy link
Contributor

@jonmeredith jonmeredith left a comment

Choose a reason for hiding this comment

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

LGTM.

Is it worth also checking the KeyspaceMetrics are created and removed and that dropping a Keyspace removes all contained table metrics?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use org.apache.cassandra.db.SystemKeyspace#ALL_TABLE_NAMES here? and similarly create ALL_TABLE_NAMES for the other keyspaces where they're missing?

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 didn't want to as that would load the whole DB, I could refactor to avoid that but felt simplest to just fork.

Copy link
Contributor Author

@dcapwell dcapwell Nov 20, 2020

Choose a reason for hiding this comment

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

I don't see that in 3.0 or trunk...

$ grep -r ALL_TABLE_NAMES src/java/
$

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better to load the tables programmatically. So compiler prompts when code changes. It can be done via

        Map<String, Collection<String>> systemTables = new HashMap<>();
        Consumer<KeyspaceMetadata> loader = meta ->
        {
            Set<String> tables = meta.tables.stream().map(t -> t.name).collect(Collectors.toSet());
            systemTables.put(meta.name, tables);
        };
        Arrays.asList(SystemKeyspace.metadata(), AuthKeyspace.metadata(), SystemDistributedKeyspace.metadata(),
                      SchemaKeyspace.metadata(), TraceKeyspace.metadata())
              .forEach(loader);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that has the same issue, we load the whole DB into the app space, so was trying to avoid that.

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 switched to doing this, I do this by loading all tables in the first instance.

@dcapwell
Copy link
Contributor Author

LGTM.

Is it worth also checking the KeyspaceMetrics are created and removed and that dropping a Keyspace removes all contained table metrics?

I thought about that but was lazy!

@dcapwell
Copy link
Contributor Author

I updated to also check the keyspace metric, there isn't a keyspace mbean to validate, so only look for the keyspace version of the metrics list

Copy link
Contributor

@jonmeredith jonmeredith left a comment

Choose a reason for hiding this comment

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

Thanks for the extra tests.

Copy link
Contributor

@yifan-c yifan-c left a comment

Choose a reason for hiding this comment

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

Looks good overall.

Copy link
Contributor

Choose a reason for hiding this comment

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

The get with overrideDefaultValue methods are not used. Not a big problem if the other patch referenced is to be merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

great to group the static variable together.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe also create constants for the metrics names? since this patch is doing some code cleanup already.
(Maybe too much work. your call)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better to load the tables programmatically. So compiler prompts when code changes. It can be done via

        Map<String, Collection<String>> systemTables = new HashMap<>();
        Consumer<KeyspaceMetadata> loader = meta ->
        {
            Set<String> tables = meta.tables.stream().map(t -> t.name).collect(Collectors.toSet());
            systemTables.put(meta.name, tables);
        };
        Arrays.asList(SystemKeyspace.metadata(), AuthKeyspace.metadata(), SystemDistributedKeyspace.metadata(),
                      SchemaKeyspace.metadata(), TraceKeyspace.metadata())
              .forEach(loader);

@dcapwell dcapwell force-pushed the bug/CASSANDRA-16095 branch from 11b0946 to d85c192 Compare December 2, 2020 21:35
blambov pushed a commit to blambov/cassandra that referenced this pull request Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants