database: sync the database before closing

This should prevent the database from losing entries on a reboot.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-17 06:53:20 -04:00
parent d9d087b9f3
commit 3f48dd5510
1 changed files with 2 additions and 1 deletions

View File

@ -298,9 +298,10 @@ class MoonrakerDatabase:
with self.lmdb_env.begin() as txn: with self.lmdb_env.begin() as txn:
for db_name, db in self.namespaces.items(): for db_name, db in self.namespaces.items():
stats = txn.stat(db) stats = txn.stat(db)
msg += f"\n{db_name}:" msg += f"\n{db_name}:\n"
msg += "\n".join([f"{k}: {v}" for k, v in stats.items()]) msg += "\n".join([f"{k}: {v}" for k, v in stats.items()])
logging.info(f"Database statistics:\n{msg}") logging.info(f"Database statistics:\n{msg}")
self.lmdb_env.sync()
self.lmdb_env.close() self.lmdb_env.close()
class NamespaceWrapper: class NamespaceWrapper: