Search code examples
cachingorientdbdiskspace

How to limit write ahead log file (WAL) used in OrientDB


I use OrientDB version 2.1.3 in embedded mode. Everything is more than fine (performance are very good compared to legacy H2 storage) but the storage space. I have very little information to store in the database and so I don't want the HDD to be wasted by temporary files.

In the database directory, I see the .wal file growing and growing (very fast). So I made some research on internet and end up with :

OGlobalConfiguration.DISK_CACHE_SIZE.setValue(16);
OGlobalConfiguration.WAL_CACHE_SIZE.setValue(16);

But this does nothing. The .wal file is keep growing and even when I delete it, it keeps growing more than 16 MB.

What can cause this file growing even with the conf set up ?

Is there a way to keep cache files under a known limit ?


Solution

  • There are no cache files in the database. Data files are cached to speed up system performance. As more RAM is allocated for disk cache, the faster your system will be. The amount of RAM allocated for disk cache does not affect WAL size.

    The properties you have set are not related to the WAL size. Instead, you should set OGlobalConfiguration#WAL_MAX_SIZE property.

    Also, the single WAL segment size is (OGlobalConfiguration#WAL_MAX_SEGMENT_SIZE) 128 megabytes so the size of the WAL can not be less than 128 megabytes, or more precisely, the value of that setting.

    So, to wrap up, properties (OGlobalConfiguration#WAL_MAX_SEGMENT_SIZE, OGlobalConfiguration#WAL_CACHE_SIZE) should be set before any call to the OrientDB classes. Ideally, they should be set through system properties (storage.wal.maxSegmentSize and storage.wal.maxSize).

    Please be aware that usage of such small values means that the disk cache will have to be forcefully flushed after very few operations to make possible to truncate database journal (WAL) and keep it in very small size.