-
Notifications
You must be signed in to change notification settings - Fork 101
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
Issue 6614 - CLI - Error when trying to display global DB stats with LMDB #6622
base: main
Are you sure you want to change the base?
Conversation
…LMDB Bug description: Displaying global monitor stats fails with key error. Caused by BDB backend keys being used when MDB is the configured DB implementation. Fix description: Ensure backend and monitor keys match the configured DB implementation. Fixes: 389ds#6614 Reviewed by:
dbpages = int(ldbm_mon['nsslapd-db-pages-in-use'][0]) | ||
dbcachefree = max(int(dbcachesize - (pagesize * dbpages)), 0) | ||
dbcachefreeratio = dbcachefree/dbcachesize | ||
if ldbm_monitor.inst_db_impl == DB_IMPL_BDB : |
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.
a space before a colon typo:)
# Check for library specific attributes | ||
if db_lib == 'bdb': | ||
assert 'dbcachehits' in monitor | ||
assert 'nsslapd-db-configured-locks' in monitor | ||
elif db_lib == 'mdb': | ||
pass | ||
assert not 'dbcachehits' in monitor |
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.
assert 'dbcachehits' not in monitor
is a preferred python style, IIRC (we might run a linter some time soon, so better to catch issues early)
src/lib389/lib389/monitor.py
Outdated
db_keys = { | ||
DB_IMPL_BDB: [ | ||
'dbcachehits', 'dbcachetries', 'dbcachehitratio', | ||
'dbcachepagein', 'dbcachepageout', 'dbcacheroevict', | ||
'dbcacherwevict' | ||
], | ||
DB_IMPL_MDB: [ | ||
'normalizeddncachetries', 'normalizeddncachehits', | ||
'normalizeddncachemisses', 'normalizeddncachehitratio', | ||
'normalizeddncacheevictions', 'currentnormalizeddncachesize', | ||
'maxnormalizeddncachesize', 'currentnormalizeddncachecount', | ||
'normalizeddncachethreadsize', 'normalizeddncachethreadslots' | ||
] | ||
} |
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 both db_keys
and db_monitor_keys
have more sense as a class variables.
So something like:
class MonitorLDBM(Monitor):
DB_KEYS = {
DB_IMPL_BDB: [
'dbcachehits', 'dbcachetries', 'dbcachehitratio',
...
],
DB_IMPL_MDB: [
'normalizeddncachetries', 'normalizeddncachehits',
...
]
}
DB_MONITOR_KEYS = {
DB_IMPL_BDB: [
'nsslapd-db-abort-rate', 'nsslapd-db-active-txns', 'nsslapd-db-cache-hit',
...
],
DB_IMPL_MDB: [
'dbenvmapmaxsize', 'dbenvmapsize', 'dbenvlastpageno',
...
]
}
def __init__(self, instance, dn=None):
super(MonitorLDBM, self).__init__(instance=instance)
self._dn = DN_MONITOR_LDBM
...
And then in the constructor we can create a copy for the class instance:
self._backend_keys = list(self.DB_KEYS.get(self.inst_db_impl, []))
self._db_mon_keys = list(self.DB_MONITOR_KEYS.get(self.inst_db_impl, []))
which later can be extended with other conditional variables.
I don't have a strong opinion here, though. But I think it'll be cleaner and more pythonic.:)
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 agree, it is cleaner. Thanks
Bug description:
Displaying global monitor stats fails with key error. Caused by BDB backend keys being used when MDB is the configured DB implementation.
Fix description:
Ensure backend and monitor keys match the configured DB implementation.
Fixes: #6614
Reviewed by: