-
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
Async operations should terminate with an error if a fatal session error occurs #5315
Comments
➤ Jonathan Reams commented: So I'm looking at the implementation of SyncSession::handle_error(). At the end of the function, before we call the error handler, if the result of the big switch statement is that next_state is None, then we check if SyncConfig::cancel_waits_on_nonfatal_error and cancel all the pending waits if it is or do nothing if it isn't. If the next_state is Inactive, then we tear down the SyncSession which should also cancel all the waits, otherwise if the error is fatal and the next_state is Error we unconditionally cancel all waits. We don't cancel any pending FLX subscription state change promises, but we easily could. I've written this integration test and it appears the test case does what we want already
Is all that's remaining here to make sure that waits for flexible sync subscription state changes also get canceled? Do we want to revisit the SyncConfig parameter that makes it so non-fatal errors don't cancel waits by default? |
Hm, looks like this has changed since I filed the ticket and indeed now async operations are canceled on fatal errors, which is great! I think for consistency's sake, we should probably also do it for flx subscriptions as a fatal error would mean your subscription change will never go through and there's no point in waiting. |
➤ michael-wb commented: The canceling of pending subscription waiters when an error occurs was updated as part of the PBS->FLX migration feature. I will be adding some tests as part of this task to verify they are working as expected. |
➤ danieltabacaru commented: I ran into a similar issue and the pending subscription notifications are not cancelled actually. That can be easily fixed. On another note, most (if not all) fatal errors transition the sync session state to inactive and not error. I think ApplicationBug and ProtocolViolation should be treated as fatal (that's an oversight from the sync session error refactoring). Completion callbacks are canceled also when the session becomes inactive (pretty much whenever an error is received as explained above or if the user pauses the session), so should the subscription callbacks also be canceled in this case? cc [~[email protected]] |
➤ nirinchev commented: I guess? I mean from a user's perspective, if something happens that would prevent the completion callback from ever firing and we know that it'll never fire, then we should notify the waiters that this is the case. |
➤ danieltabacaru commented: I would cancel the subscription "callbacks" because the user may use the promise/future api (unlike waiting for the callback to be called) and be blocked until the session is resumed. The completion callbacks don't actually block the user, it's just annoying that they would not be called if they weren't cancelled. You can argue that when the session is paused, the completion callbacks could be de-registered and registered again when the session is resumed (currently the user has to register them again). They would have to register the notification for the subscription again too (but at least there is some uniformity). |
➤ danieltabacaru commented: we can't really know if the callbacks would fire (I guess that's why we play it safe and cancel them when the session becomes inactive) |
All async wait operations -
Realm::get_synchronized_realm
,wait_for_download_completion
,get_state_change_notification
will wait forever in the event of a session error. We should instead cancel the wait and propagate the error back to the waiter so that they can handle it. To repro, make an additive schema change when dev mode is off and callwait_for_upload_completion
. The logs should say something like:But the wait callback will not be invoked.
The text was updated successfully, but these errors were encountered: