Repository navigation
crimson/common/tri_mutex: make locking/promotion atomic if possible - #56844
Conversation
There was a problem hiding this comment.
the commit message is missing the problem description, the root cause analysis, and the summary of this change. could you please elaborate a little bit on the root cause of
tri_mutex::promote_from_read(): Assertion `readers == 1' failed.
and how this change addresses this problem?
There was a problem hiding this comment.
My understanding see #55488 (comment) that caused writers == 1 failure.
I think the issue is similar that func (to promote and load-obc) isn't called immediately upon the 1st locked. The returned future allows the 2nd reader enter and lock (causing readers > 1) even the future is available, before func is called.
Making lock() to return nullopt instead of a ready future in this change makes the 1st locking and calling func atomic.
Note that we have fixed several issues related to out-of-order and ready future.
There was a problem hiding this comment.
Added more information in the commit message.
There was a problem hiding this comment.
I don't see how this actually helps. The bulk of the changes here allow for the various lock invocations to dynamically return std::nullopt allowing us to take the else branch of the if statement above
return seastar::futurize_invoke(func
).finally([&lock, obc] {
lock.unlock();
});
That only solves the atomicity problem it if actually happens to return std::nullopt, though. For this to be an actual solution, we'd have to know statically that it really will. In that case, why allow the function to return a non-ready future at all?
I think this is essentially symmetric to the other similar PR that attempted to return a std::optional<future<>> -- the right solution is to identify why we are confident that a particular pathway doesn't need to block and directly call a variant that will never block.
There was a problem hiding this comment.
I see, if my understanding is correct above, we should be able to convert read/write promotion to a non-block version, will try.
BTW, the test with the current change looks passing, see #56912 (comment)
There was a problem hiding this comment.
The original promotion is already synchronous, so spcialize _with_promotion() to make sure the function is always called atomically instead of optional.
Proceed to tests.
99b35f8 to
b47381d
Compare
|
jenkins test api |
|
jenkins test api |
b47381d to
eb9fead
Compare
|
jenkins retest this please |
Signed-off-by: Yingxin Cheng <[email protected]>
Signed-off-by: Yingxin Cheng <[email protected]>
eb9fead to
c819baf
Compare
There was a problem hiding this comment.
why are we including this header?
There was a problem hiding this comment.
It's for seastar::now().
There was a problem hiding this comment.
this change does not belong to this commit.
There was a problem hiding this comment.
i understand that we've been putting & near the variable. but & is part of the type, see https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines for more examples, so..
There was a problem hiding this comment.
probably could put something like
template <typename Mutex, typename Func>
auto _with_lock(Mutex& mutex, Func&& func) {
Ref obc{this};
const std::lock_guard<Mutex> lock{mutex};
co_return co_await seastar::futurize_invoke(func);
}?
IMHO, no need to use the concept for enforcing the type constraints. because future<> cannot be discarded with [[nodiscard]] attribute. i think SFINAE should work here, so no need to use a new name, unless we need to make it more visible. but for what reason?
There was a problem hiding this comment.
Seems not working directly:
/root/ceph/src/crimson/osd/object_context.h:138:15: error: ‘co_await’ cannot be used in a function with a deduced return type
138 | co_return co_await seastar::futurize_invoke(func);
| ^~~~~~~~
/root/ceph/src/crimson/osd/object_context.h:135:8: error: unable to find the promise type for this coroutine
135 | auto _with_promoted_lock(Mutex& mutex, Func&& func) {
Will fallback to the original version.
There was a problem hiding this comment.
thanks. will try to come up with a followup.
There was a problem hiding this comment.
if we have to add a concept for BasicLockable. might want to put something like:
template<typename Mutex>
concept basic_lockable = requires(Mutex m) {
{ m.lock() } -> std::same_as<void>;
{ m.unlock() } -> std::same_as<void>;
};There was a problem hiding this comment.
Discarded the concept.
|
left a couple comment. also, could s/if available/if possible/ or s/if available/when appropriate/ in the title of this PR. |
Signed-off-by: Yingxin Cheng <[email protected]>
4136c2d to
caf8983
Compare
Specifically, make promotion atomic with load-obc to fix assert(readers/writers == 1) failures. Fixes: https://tracker.ceph.com/issues/65451 Signed-off-by: Yingxin Cheng <[email protected]>
caf8983 to
676947e
Compare
|
jenkins test api |
Fixes: https://tracker.ceph.com/issues/65451
Signed-off-by: Yingxin Cheng [email protected]
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e