Skip to content
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

Race in Schedule Job algorithm handling of equivalent job promises #853

Closed
wanderview opened this issue Mar 23, 2016 · 6 comments
Closed
Milestone

Comments

@wanderview
Copy link
Member

Currently the Schedule Job algorithm says:

If job is equivalent to lastJob, append job’s promise to lastJob’s list of equivalent job promises.

The intention being to combine repeated jobs (like updates) into a single job where possible.

There is a race, however. Some jobs resolve their promises before Finish Job is complete. For example, the Install algorithm calls Resolve Job Promise on step 6, but may call Finish Job much later at step 19. In between these steps the algorithm waits for the install event to be fired and handled.

If Schedule Job runs between when Resolve Job Promise and Finish Job are invoked, then appending the new promise won't have any effect. It will never get resolved.

@wanderview wanderview added this to the Version 1 milestone Mar 23, 2016
@wanderview
Copy link
Member Author

I think maybe the easiest solution would be to set a flag when the Resolve Job Promise is run. Then we can simply avoid the coalescing optimization if that flag is set.

@jungkees
Copy link
Collaborator

Ah.. right. Thanks for spotting this!

I think there are two options:
(A) as suggested

I think maybe the easiest solution would be to set a flag when the Resolve Job Promise is run. Then we can simply avoid the coalescing optimization if that flag is set.

(B) For the equivalent incoming job, if the lastJob's promise has settled already, settle job's promise accordingly.

(A) seems simpler but then #800 (comment) won't be a solution for .update() failing in oninstall any more (as the job will be queued). (B) doesn't involve the same issue but will have to additionally store the state of the promise settlement values for the lastJob. Which option would be better?

@wanderview
Copy link
Member Author

My initial gut feeling would be to explicitly handle the "update() call during install event" case and do case (a) for aggregation. I'm not sure I like keeping state around just in case someone calls update().

I think case (a) is also closer to what devs might expect. If I see a previous update() promise resolve, and then immediately call update() again, I think I would expect a second update process to run.

@wanderview
Copy link
Member Author

If we do option (a), we could put this check in the "job is equivalent" check. If one job has its promise fufilled, but the other does not, then they are not equivalent.

@jungkees
Copy link
Collaborator

Agreed on (a). Re the promise check, let's just add checking if the promise has settled in Schedule Job instead of adding this condition to the definition of "equivalent" jobs. (We don't need to add any additional flag even.)

@jungkees
Copy link
Collaborator

#800 (comment) should be addressed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants