-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return an error when scheduling a reducer with a long delay (#77)
Prior to this commit, it was possible for a module to crash SpacetimeDB by scheduling a reducer with a delay longer than ~2yrs. This was due to our use of `tokio_utils::time::DelayQueue` to handle scheduling. `DelayQueue`'s internal data structure imposes a limit of 64^6 ms on delays, a little more than two years. Attempting to insert with a delay longer than that panics. With this commit, we avoid the panic by checking ourselves that the requested delay is not longer than 64^6 ms. This requires bubbling a `ScheduleError` up from `Scheduler::schedule` to `WasmInstanceEnv::schedule`, where it is converted into a `RuntimeError` which crashes the module. `Scheduler::schedule` could also fail because its transaction to compute a new id was fallible. This seems unlikely to ever fail, and if it does, we have bigger problems, so `unwrap`ping might still be reasonable for that case, but this commit converts it into a handle-able `Err`or anyway, as there's essentially no cost in complexity to doing so.
- Loading branch information
Showing
3 changed files
with
100 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters