diff options
author | Mikael Pettersson <[email protected]> | 2015-05-31 11:38:41 +0200 |
---|---|---|
committer | Mikael Pettersson <[email protected]> | 2015-05-31 11:38:41 +0200 |
commit | 7a2da8a21c947503591b19c9ec2a262b7b2fb581 (patch) | |
tree | 9b0914729167c57600bad31da3affaa56d7ba154 /lib | |
parent | efbfe9602983ff451b864e557bdf3733222b78ba (diff) | |
download | otp-7a2da8a21c947503591b19c9ec2a262b7b2fb581.tar.gz otp-7a2da8a21c947503591b19c9ec2a262b7b2fb581.tar.bz2 otp-7a2da8a21c947503591b19c9ec2a262b7b2fb581.zip |
mnesia: don't delete log file on emfile error
If the VM runs into the process' file descriptor limit when mnesia
tries to open (not create) a disk_log file, the open fails with an
emfile error. Mnesia misinterprets this as a corrupt file, deletes
it, tries to create a new empty disk_log file, which also fails.
The end result is a corrupt database on disk.
Check for emfile errors and error out immediately without deleting
the file in those cases.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mnesia/src/mnesia_log.erl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/mnesia/src/mnesia_log.erl b/lib/mnesia/src/mnesia_log.erl index d2fd04a60b..eda6be4e25 100644 --- a/lib/mnesia/src/mnesia_log.erl +++ b/lib/mnesia/src/mnesia_log.erl @@ -349,6 +349,8 @@ open_log(Name, Header, Fname, Exists, Repair, Mode) -> mnesia_lib:important("Data may be missing, log ~p repaired: Lost ~p bytes~n", [Fname, BadBytes]), Log; + {error, Reason = {file_error, _Fname, emfile}} -> + fatal("Cannot open log file ~p: ~p~n", [Fname, Reason]); {error, Reason} when Repair == true -> file:delete(Fname), mnesia_lib:important("Data may be missing, Corrupt logfile deleted: ~p, ~p ~n", |