-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added thread safety to session wrapper checks #7069
Conversation
Pull Request Test Coverage Report for Build michael.wilkersonbarker_911
💛 - Coveralls |
|
How was the race manifesting? |
@@ -1457,18 +1509,24 @@ bool SessionWrapper::wait_for_download_complete_or_client_stopped() | |||
void SessionWrapper::refresh(std::string signed_access_token) | |||
{ | |||
// Thread safety required | |||
REALM_ASSERT(m_initiated); | |||
REALM_ASSERT(!m_finalized); | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially very suspicious code when you guard just a few variables with very limited scope. Looks like this class serves multiple purposes... I'd need to look at it more carefully. It's not obvious it this fix just silence particular tsan warning or solves the issue with this class design and concurrent access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what i can tell, this fixes the linked issue with data race on force_close. I think though we should make this fix cleaner. @michael-wb do you have any plans for this change in near term?
@@ -228,6 +232,8 @@ class SessionWrapper final : public util::AtomicRefCountBase, DB::CommitListener | |||
// Must only be accessed from the event loop thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still true?
@@ -228,6 +232,8 @@ class SessionWrapper final : public util::AtomicRefCountBase, DB::CommitListener | |||
// Must only be accessed from the event loop thread. | |||
SessionImpl* m_sess = nullptr; | |||
|
|||
// @} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move these fields to some other class, and make it fully threadsafe? This is a bit unsettling that only part of this class is supposed to be accessed from different threads. It's error prone.
What, How & Why?
There was a data race during client shutdown using
force_close()
that was occasionally reported by the TSAN evergreen tests. These changes add mutex thread safety around the parameters that can be modified by multiple threads.Fixes #6844
☑️ ToDos
[ ] 🚦 Tests (or not relevant)[ ] C-API, if public C++ API changed.