mirror of
https://github.com/facebook/sapling.git
synced 2024-10-04 22:07:44 +03:00
better error message when eden fails to start flock
Summary: Sometimes when there are two EdenFS's attempting to start at the same time we run into flock error. It's possible we need to take the lock earlier to avoid two eden's from getting this far in the process. Seems like this locking code throws instead of returning false, so maybe this error should just be swallowed and we fall back to the "another eden is running code path". While we sort that out let's at least give the user a more informative error message. Reviewed By: genevievehelsel Differential Revision: D51903606 fbshipit-source-id: 062921a6899a9e62b7770a199d329bf233f1168e
This commit is contained in:
parent
e584c0efb3
commit
18936d5a40
@ -31,8 +31,16 @@ EdenStateDir::~EdenStateDir() = default;
|
||||
bool EdenStateDir::acquireLock() {
|
||||
auto lockFile =
|
||||
folly::File(lockPath_.value(), O_WRONLY | O_CREAT | O_CLOEXEC);
|
||||
if (!lockFile.try_lock()) {
|
||||
return false;
|
||||
try {
|
||||
if (!lockFile.try_lock()) {
|
||||
return false;
|
||||
}
|
||||
} catch (const std::system_error& ex) {
|
||||
throw std::runtime_error(fmt::format(
|
||||
"Error acquiring lock: {}. Another EdenFS process may have raced with "
|
||||
"this one. Try `eden start --wait` to check if EdenFS is starting and "
|
||||
"watch it's progress.",
|
||||
ex.what()));
|
||||
}
|
||||
|
||||
takeoverLock(std::move(lockFile));
|
||||
|
Loading…
Reference in New Issue
Block a user