Skip to content

Commit 991e2b0

Browse files
committed
Catch all exceptions when de-serializing
If an exception were to escape during an event log restore, phosphor-log-manager would just keep continuously crashing and restarting. To prevent this, just catch all exceptions and move the file that caused it to /var/lib/phosphor-logging/corrupt_error so that it is kept around for debug if desired. Only the most recent bad file is kept. Tested: Instead of crashing, the daemon can now stay up: ``` Mar 19 14:10:06 p10bmc phosphor-log-manager[2953]: Failed restoring /var/lib/phosphor-logging/errors/381: std::bad_alloc /var/lib/phosphor-logging# ls -l /var/lib/phosphor-logging/corrupt_error -rw-r--r-- 1 root root 374 Mar 19 13:39 /var/lib/phosphor-logging/corrupt_error ``` Change-Id: Iaa30dff261bbbe048cbca5678f2940cb2a8ed1df Signed-off-by: Matt Spinler <[email protected]>
1 parent 760b981 commit 991e2b0

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

elog_serialize.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,13 @@ bool deserialize(const fs::path& path, Entry& e)
149149
}
150150
return false;
151151
}
152-
catch (const cereal::Exception& ex)
152+
catch (const std::exception& ex)
153153
{
154-
lg2::error("{EXCEPTION}", "EXCEPTION", ex);
155-
fs::remove(path);
156-
return false;
157-
}
158-
catch (const std::length_error& ex)
159-
{
160-
// Running into: USCiLab/cereal#192
161-
// This may be indicating some other issue in the
162-
// way vector may have been used inside the logging.
163-
// possibly associations ??. But handling it here for
164-
// now since we are anyway tossing the log
165-
// TODO: openbmc/phosphor-logging#8
166-
lg2::error("{EXCEPTION}", "EXCEPTION", ex);
167-
fs::remove(path);
154+
lg2::error("Failed restoring {PATH}: {EXCEPTION}", "PATH", path,
155+
"EXCEPTION", ex);
156+
// Save it for later debug. Just write over any previous ones.
157+
auto saveDir = paths::error().parent_path();
158+
fs::rename(path, saveDir / "corrupt_error");
168159
return false;
169160
}
170161
}

0 commit comments

Comments
 (0)