-
Notifications
You must be signed in to change notification settings - Fork 61
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
Guard notifying outdated scheduler #1559
Conversation
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.
Looks great.
scope.launch { | ||
try { | ||
printlntid("on dispatcher") | ||
realm_wrapper.realm_scheduler_perform_work(scheduler) | ||
if (!cancelled.value) { |
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.
Doesn't core wait until the jobs have been executed to release the scheduler?
Also, this guard does not cover 100% of the cases, the pointer might have been released just after accessing cancelled
.
Because closing and job execution happens on the same thread there is no way that the Realm gets closed while executing the Job.
Instead of guarding the Closing the coroutine there would cancel any pending core jobs that were posted. |
If we have a user supplied scheduler then we cannot close it. There could also potentially be multiple scheduler in the same scope so feels better to use the exact signal from the user-data-free-callback to guard this. |
Yes, we shouldn't be closing the main The For example instead of working with the main |
But coroutine scopes are not preemptive so you are not guaranteed that any running coroutine will be immediately aborted. But you are right the current guard is actually not good enough ... though it looks like some of the schedulers in core uses a similar flag so might be that there are some other guarantees in effect here 🤔 |
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.
Nice fix 👍 it looks like io.realm.kotlin.test.darwin.CoroutineTests.dispatchBetweenThreads
is failing for macOS on CI
The failing test is caused by trying to clean up the |
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.
Awesome 💯
@@ -753,9 +753,10 @@ class SyncedRealmTests { | |||
.mutableRealmIntField | |||
.increment(1) | |||
} | |||
realm.syncSession.uploadAllLocalChanges(10.seconds) |
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.
Great catch 🙈, but any reason you are adding a timeout? The first upload doesn't have one
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.
I added it because it would highlight what action is actually not executing as expected instead of just timeout out on the recipient side. I just added if for the uploads that I inserted, but just didn't walk over the rest of the code.
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.
Ok 👍
TODOs:
Closes #1543
Closes #1558
Closes #1561