[erlang-questions] Erlang and fsync

Magnus Ahltorp map@REDACTED
Fri Aug 1 16:32:28 CEST 2014


When a UNIX program wants to ensure that a file and its contents have been written to disk, the normal way is to call fsync(). In Erlang, there is a file:sync that as far as I can see just calls fsync(). There are, however, two problems with this:

1) Since directories are not openable with file:open, it is not possible to fsync directories. This is a problem, since fsync() doesn't necessarily ensure that the directory entry of a newly created file has reached the disk.
2) fsync() blocks the thread that executes it until the data is submitted to the disk. A number of Erlang processes doing fsync() could totally wreck the realtime performance of the system, since fsync() can take a long time.

I tried to search through the mail archives, but I couldn't find any solutions to this.

How do people solve this, or don't other people using Erlang want (soft) guarantees that their data is on disk? Do I have to write the code in C and send the files to be fsync:ed over a port?


More information about the erlang-questions mailing list