Hi,
I understand that the DB size has an upper limit set by the call to mdb_env_set_mapsize . I wonder what is the best strategy for growing the size. From what I read, the put operations of either txn or cursor may fail with the MDB_MAP_FULL error but then it is too late to change the DB size. On the other hand I didn't find in mdb_env_stat (or perhaps I didn't understand) any information suggesting how full is the DB so I can't really implement any strategy for preemptively growing the DB based on the used space.
Did I miss anything?
Cheers, Shmul
On Mar 16, 2013, at 15.34, Shmulik Regev shmulbox@gmail.com wrote:
Hi,
I understand that the DB size has an upper limit set by the call to mdb_env_set_mapsize . I wonder what is the best strategy for growing the size.
i'm not sure i'd ever consider attempting to constantly adjust a max size setting ahead of growth of the database to make much sense. that isn't what that setting is for. that setting is a "security" setting. a limit to protect the environment [e.g. the os], not something you should pick a value for based on your best attempt at guessing how large the db might get.
-ben
Shmulik Regev wrote:
Hi,
I understand that the DB size has an upper limit set by the call to mdb_env_set_mapsize . I wonder what is the best strategy for growing the size.
The best strategy is to initially pick a large enough size that growing it is never an issue. E.g., set it to the amount of free space on the disk partition where the DB resides. As the docs state, when the DB is actually in use, there's no guarantee that there will be enough free system resources left for a resize attempt to even succeed. I.e., if you initially choose a small size, by the time you need to deal with it it may be too late.
From what I read, the put operations of either txn or cursor may fail with the MDB_MAP_FULL error but then it is too late to change the DB size. On the other hand I didn't find in mdb_env_stat (or perhaps I didn't understand) any information suggesting how full is the DB so I can't really implement any strategy for preemptively growing the DB based on the used space.
Did I miss anything?
There are 2 sets of information you can use for an estimate.
1) MDB_stat gives you the page size.
2) MDB_envinfo tells the mapsize and the last_pgno. If you divide mapsize by pagesize you'll get max pgno. The MAP_FULL error is returned when last_pgno reaches max pgno.
This is also tempered by the contents of the freelist. The mdb_stat command can tell you how many pages are on the freelist. (mdb_stat -f). The DB isn't actually full until the freelist is used up, and last_pgno is maxed out.
openldap-technical@openldap.org