DETS table auto_save behaviour

Nicolas Martyanoff khaelin@REDACTED
Tue May 25 08:43:05 CEST 2021


I am unsure about the behaviour of DETS regarding saving. 

The documentation indicates:

    all operations performed by Dets are disk operations

Which seems to hint that every single insertion ends up on disk. Good.

But then:

    {auto_save, auto_save()} - The autosave interval. If the interval is
    an integer Time, the table is flushed to disk whenever it is not
    accessed for Time milliseconds. A table that has been flushed
    requires no reparation when reopened after an uncontrolled emulator

This is ambiguous: does it means that entries will be buffered in memory
and only written to disk during the auto save operation (therefore some
operations are not actually disk operations), or does it mean that DETS
always writes to disk without sync-ing (using fsync or equivalent), and
synchronization occurs during the auto save operation ?

In any case, am I correct in assuming that DETS does not offer any way
to guarantee that entries are actually written on disk, meaning that an
application crash would lead to a loss of every entry written since the
last auto_save operation ?

I was hoping to use DETS as a local persistent buffer in case data
cannot be written to a remote database, but it seems impossible to
guarantee that every entry is being sync-ed to disk.

Thank you in advance.


Nicolas Martyanoff

More information about the erlang-questions mailing list