-
Type: Bug
-
Resolution: Unresolved
-
Priority: Trivial - P5
-
None
-
Affects Version/s: None
-
Component/s: None
-
2 - S (<= 1 week)
-
4173
-
Not Needed
As a rule, if a commit happens, all waiters must be notified. It is also OK to wake waiters if a commit doesn't happen, but we must ensure there is never a missed wakeup.
There seems to be at least a few potential issues here https://github.com/realm/realm-core/blob/2946c7a52449d3b8d038ff03d896b651615b8ad4/src/realm/db.cpp#L2287-L2295
- The update of latest_version_number could be torn and needs to be performed atomically. This applies at least to all 64-bit values. Technically it applies to all modifications that need to be crash-safe, but in practice it is more of a problem for values that aren't 1, 2, or 4 bytes wide.
- The call to m_new_commit_available.notify_all() needs to happen earlier, at least before the update of latest_version_number. There may also be a related bug inside of InterprocessCondVar, but I will file a separate ticket for that (#4174 /
RCORE-458) - We may need to protect earlier inside the critical section, right before a commit is guaranteed to happen. We must hold the m_controlmutext continuously at least from before we notify until after we update latest_version_number to ensure there are no missed wakeups (or wakeups that see the old version and go back to sleep).
- related to
-
RCORE-458 InterprocessCondVar implementation on windows isn't safe
- Closed