-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-7282. Add EstimatedKeyCount metrics for SCM DB #3791
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
| checkTableStatus(statefulServiceConfigTable, | ||
| STATEFUL_SERVICE_CONFIG.getName()); | ||
|
|
||
| mxBean = MBeans.register("SCMMetadataStore", "SCMMetadataStoreImpl", |
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 suspect this needs an "unRegister" in the stop() method?
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.
@sodonnel Thank you for your reminder, updated the PR, please have a look.
| } | ||
|
|
||
| @Override | ||
| public String getEstimatedKeyCount() { |
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 typed this earlier, but forgot to post it. This means we are going to have a metric where the value is a command seperated list of key value pairs, eg:
metric -> tab1 : 10, tab2 : 15 ... etc.
Have we got any other metrics like this? Would it be better if we had a metric for each table directly, so they can be charted etc if needed? Ie
SCMEstimatedKeyCountTab1 -> 10
SCMEstimatedKeyCounttab2 -> 15
etc
You would need to have dynamic metric names for this, but there is an example of doing that in ReplicationManagerMetrics
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.
@sodonnel Thank you for the advice. Updated the PR, please have a look.
| public class SCMMetadataStoreImpl implements SCMMetadataStore { | ||
|
|
||
| public static final Set<DBColumnFamilyDefinition<?, ?>> COLUMN_FAMILIES = | ||
| new HashSet<>(Arrays.asList( |
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.
Do we need this extra map containing all the tables? They are already stored in the tableMap, so we can iterate it to list out all the tables.
My concern is that if someone later adds a new table, they can easily miss adding it to this map, and then the metric will not automatically appear.
If we drive it off the tableMap, then there is nothing special to do around metrics when adding a new 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 it might be necessary, when I use the tableMap from the StoreImpl, the metrics class will invoke NullPointerException.
| try { | ||
| return e.getKey() + " : " + e.getValue().getEstimatedKeyCount(); | ||
| } catch (IOException ex) { | ||
| ex.printStackTrace(); |
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.
Should we send this to the logger, rather than stderr?
| count = scmMetadataStore.getTableMap().get(e.getKey()) | ||
| .getEstimatedKeyCount(); | ||
| } catch (IOException exception) { | ||
| // Ignore exception here. |
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 should probably log exceptions here rather than totally ignore them.
...s/server-scm/src/test/java/org/apache/hadoop/hdds/scm/metadata/TestSCMMetadataStoreImpl.java
Show resolved
Hide resolved
| "EstimatedKeyCount", | ||
| "Tracked estimated key count of all column families"); | ||
|
|
||
| private static final Map<String, MetricsInfo> ESTIMATED_KEY_COUNT_METRICS |
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 understand - you would get a null pointer here, as this is a static definition. What about moving this to be an instance variable and build the Interns.info objects when this metrics object is created? That means we still have a cache of the names inside the object to avoid allocations each time the metrics are requested.
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.
Good idea. Updated the PR, please have a look.
|
This change looks good now - thanks for taking on the changes. However there is one more thing I think we should change. We are calling Could you remove the |
|
@sodonnel Sure, updated the PR, please have a look. |
sodonnel
left a comment
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, if we get a green CI run.
|
I think the test failiures are related to this change. I tried running TestContainerStorageManagerHA from intellij and it fails with: Same error two times. I tried with the master branch and the tests run fine, so there is something related to this test which is causing the problem. |
| builder.tag(ESTIMATED_KEY_COUNT, gson.toJson(keyCountMap)); | ||
| } | ||
|
|
||
| public static void unRegister() { |
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.
Does unRegister need to be synchronized too, as it can access instance while register is running? I'm not sure if it does or not, but might be safer to make it synchronized.
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.
Sure, let me add it.
What changes were proposed in this pull request?
This ticket is to add the metric of EstimatedKeyCount for SCM DB.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-7282
How was this patch tested?
unit test.