You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #3293, apps/schedule can fail due to a race condition. In the success case, the following sequence occurs:
the test's .click(selector) causes the JS in the test app to make some HTTP or websocket request to the grain backend.
the grain's backend makes some request over capnproto RPC to the sandstorm meteor backend to schedule a job to be run in 5 minutes
the sandstorm meteor backend's capnproto interface implementation inserts some record into the mongo database
the test's .execute('Meteor.call("runDueJobsAt", ' + firstCheck.toString() + ');') triggers a request to the sandstorm meteor backend
the meteor backend runs a db query for scheduled jobs due at a particular time, finds a record, and triggers the scheduled job.
But there's actually no synchronization forcing 4 to come after 3, so there's another sequence of events that is also possible:
the test's .click(selector) causes the JS in the test app to make some HTTP or websocket request to the grain backend.
the grain's backend makes some request over capnproto RPC to the sandstorm meteor backend to schedule a job to be run in 5 minutes
the test's .execute('Meteor.call("runDueJobsAt", ' + firstCheck.toString() + ');') triggers a request to the sandstorm meteor backend
the meteor backend runs a db query for scheduled jobs due at a particular time, finds no records, and triggers nothing.
the sandstorm meteor backend's capnproto interface implementation, responding to the RPC in step 2, inserts some record into the mongo database. In five minutes, it might fire, but our test framework has given up by then.
The solution is to enforce the intended ordering with a barrier of some sort. One way to go about that would be:
Make the test app grain backend return something in the request to schedule the job, but only once the sandstorm backend has acknowledged the request.
Make the test app frontend change something in the page when that request completes successfully (adding an element with an ID like #success-oneshot would do)
Make the test itself wait on that frontend change to appear before calling the runDueJobsAt Meteor method.
(We've worked around this in the meantime with a five-second pause, but that increases the total runtime of the testsuite, and it'd be good to fix this the "right" way)
The text was updated successfully, but these errors were encountered:
Yes, the race condition I identified was fixed by #3349, so I'll close this.
There's a much-less-pressing code health thing where we still call .pause() in a couple places when ideally we'd be checking for a condition until a deadline instead, but that can be a separate ticket if we want to write that down.
As discussed in #3293,
apps/schedule
can fail due to a race condition. In the success case, the following sequence occurs:.click(selector)
causes the JS in the test app to make some HTTP or websocket request to the grain backend..execute('Meteor.call("runDueJobsAt", ' + firstCheck.toString() + ');')
triggers a request to the sandstorm meteor backendBut there's actually no synchronization forcing 4 to come after 3, so there's another sequence of events that is also possible:
.click(selector)
causes the JS in the test app to make some HTTP or websocket request to the grain backend..execute('Meteor.call("runDueJobsAt", ' + firstCheck.toString() + ');')
triggers a request to the sandstorm meteor backendThe solution is to enforce the intended ordering with a barrier of some sort. One way to go about that would be:
runDueJobsAt
Meteor method.(We've worked around this in the meantime with a five-second pause, but that increases the total runtime of the testsuite, and it'd be good to fix this the "right" way)
The text was updated successfully, but these errors were encountered: