Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jchapma
Copy link
Contributor

@jchapma jchapma commented Feb 17, 2025

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:

…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 :
Copy link
Member

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

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)

Comment on lines 121 to 134
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'
]
}
Copy link
Member

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.:)

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 agree, it is cleaner. Thanks

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.

CLI - Error when trying to display global DB stats with LMDB
2 participants