From 18936d5a406773de4d7a63628014b8a15edc7f12 Mon Sep 17 00:00:00 2001 From: Katie Mancini Date: Wed, 6 Dec 2023 15:21:09 -0800 Subject: [PATCH] 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 --- eden/fs/service/EdenStateDir.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eden/fs/service/EdenStateDir.cpp b/eden/fs/service/EdenStateDir.cpp index 77070d8845..7437d0555f 100644 --- a/eden/fs/service/EdenStateDir.cpp +++ b/eden/fs/service/EdenStateDir.cpp @@ -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));