LightningDB.LightningException: MDB_MAP_FULL Exception on large transaction

230 views
Skip to first unread message

Famous

unread,
Apr 23, 2016, 2:52:48 PM4/23/16
to Siaqodb - NoSQL embedded database for .NET
I wanted to see the insert speed of siaqodb so I set up a simple project.

OS: Windows 7 64 Bit
Memory: 8 GB



    public class Employee
    {
        public int OID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public int Age { get; set; }
        public string City { get; set; }
    }


and my code to insert into the db


        public void InsertToDb()
        {
            var siaqodb = new Siaqodb(@"C:\testdb\");
            var transaction = siaqodb.BeginTransaction();

            for (var i = 0; i < 300000; i++)
            {
                var employee = new Employee
                {
                    FirstName = $"First {i}",
                    LastName = $"Last {i}",
                    Age = i,
                    City = "New York"
                };

                siaqodb.StoreObject(employee, transaction);
            }

            transaction.Commit();
        }


and I end up getting this exception:


************** Exception Text **************
LightningDB.LightningException: MDB_MAP_FULL: Environment mapsize limit reached
   at LightningDB.Native.NativeMethods.ExecuteHelper(Func`2 action, Func`2 shouldThrow)
   at LightningDB.Native.NativeMethods.Execute(Func`2 action)
   at LightningDB.LightningTransaction.Put(LightningDatabase db, Byte[] key, Byte[] value, PutOptions options)
   at #=qVasPneouG3a2VEMh3CXSJTT3iFBHppwpNfmZM5Us1lM=.#=q8O7pgv0rvyEQcQC444si2A==(Object #=qcH_CAVTMNa9weqXmFvPUWw==, #=q0ff40JNLc6qMwoy7V2vgPmRx_YsoRjBL311LTWPo6b8= #=qMiu_U0fDvTxWzO1NNl41sQ==, #=qtTOnNFVme6LlSQ92pA9O4N0r8UDaRpl6U6Qi9pZGePE= #=qbMwAzzDcPxxKGEpmtkndrA==, LightningTransaction #=qXOIx3SoLWlYlWfxYAGTZBg==)
   at Sqo.Siaqodb.StoreObject(Object obj, ITransaction transaction)


Siaqodb Support

unread,
Apr 25, 2016, 7:17:26 AM4/25/16
to Siaqodb - NoSQL embedded database for .NET, few...@gmail.com
Siaqodb needs the size of database specified upfront. By default the database size is 50MB. If you want to test/work with bigger db size, just set it in ctor, example:

Siaqodb db=new Siaqodb(dbPath,300 * 1024 * 1024);

This will open the db and set its size to 300 MB. 

But if your db size is totally unpredictable, Siaqodb also offer Autogrowth feature:

SiaqodbConfigurator.AutoGrowthThresholdPercent

and
 
SiaqodbConfigurator.AutoGrowthSize

properties, should be used like this:

SiaqodbConfigurator.AutoGrowthThresholdPercent has default value 80 which means that when the DB space used is more than 80% of the file size, when you will open the database, it will automatically re-size  to currentFileSize + SiaqodbConfigurator.AutoGrowthSize. 

SiaqodbConfigurator.AutoGrowthSize is in bytes and the default value is 5*1024*1024 (5 MB).

but you will have to Close() the database and Reopen to readjust the size. So you can manage that by checking what is the actual used size and if, for example, exceed 80%, you can close and reopen the db, example:

  private bool ShouldIncreaseDBSize()
       
{
           
return this.siaqodb.DbInfo.UsedSize > 0.8m * this.siaqodb.DbInfo.MaxSize;
       
}


and in your repo, in storing data methods, you could do:

public void StoreObject(Employee  employee)
{
 
if (this.ShouldIncreaseDBSize())
           
{
               
var storagePath = this.siaqodb.DbInfo.Path;


               
this.siaqodb.Close();
               
this.siaqodb.Open(storagePath);
           
}
   
this.siaqodb.StoreObject(employee);
}



And it will automatically increase with the amount set in 
SiaqodbConfigurator.AutoGrowthSize

Reply all
Reply to author
Forward
0 new messages