Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't panic when unordered operations are processed by scheduler
When the scheduler processes multiple operations, it stores then in a slice according to their `Index` field: ```go store[op.Id][op.Index] = op ``` To ensure the slice has the capacity to store the item, there's an allocation block, right before: ```go if len(store[op.Id]) <= op.Index { store[op.Id] = append(store[op.Id], op) } ``` However, the code above panics with "index out of range" if the delta between the slice length and the operation index is greater than 1 -- for instance, if the slice is empty and the first operation has index 2. To fix it, we must perform the `append` multiple times: ```go for len(store[op.Id]) <= op.Index { store[op.Id] = append(store[op.Id], op) } ```
- Loading branch information