Skip to content

Commit

Permalink
Externalize the size limit for LMDB map size for Baser to an environm…
Browse files Browse the repository at this point in the history
…ent variable. (#810)

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Jun 28, 2024
1 parent e1bf1a3 commit d70d148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/keri/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ def reopenDB(db, clear=False, **kwa):
db.close(clear=clear)


KERIBaserMapSizeKey = "KERI_BASER_MAP_SIZE"


class Baser(dbing.LMDBer):
"""
Baser sets up named sub databases with Keri Event Logs within main database
Expand Down Expand Up @@ -935,6 +938,9 @@ def __init__(self, headDirPath=None, reopen=False, **kwa):
self._kevers = dbdict()
self._kevers.db = self # assign db for read through cache of kevers

if (mapSize := os.getenv(KERIBaserMapSizeKey)) is not None:
self.MapSize = int(mapSize)

super(Baser, self).__init__(headDirPath=headDirPath, reopen=reopen, **kwa)

@property
Expand Down
3 changes: 2 additions & 1 deletion src/keri/db/dbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ class LMDBer(filing.Filer):
TempSuffix = "_test"
Perm = stat.S_ISVTX | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR # 0o1700==960
MaxNamedDBs = 96
MapSize = 104857600

def __init__(self, readonly=False, **kwa):
"""
Expand Down Expand Up @@ -378,7 +379,7 @@ def reopen(self, readonly=False, **kwa):

# open lmdb major database instance
# creates files data.mdb and lock.mdb in .dbDirPath
self.env = lmdb.open(self.path, max_dbs=self.MaxNamedDBs, map_size=104857600,
self.env = lmdb.open(self.path, max_dbs=self.MaxNamedDBs, map_size=self.MapSize,
mode=self.perm, readonly=self.readonly)

self.opened = True if opened and self.env else False
Expand Down

0 comments on commit d70d148

Please sign in to comment.