When updating a course's availability settings, we touch all of the
users in the course. This causes locks in production when there's
lots of users enrolled in several large courses being updated. In
the case where we are updating availability settings, we'll skip
touching user objects if the row is locked - another process will
update the timestamp.
flag = none
closes LS-3018
Test plan:
- In a rails console, get a relation of courses doing something
like `relation = Course.where(id: [1, 2, 3])`
- Run `relation.touch_all_skip_locked`
- Expect the updated_at timestamp of each course to be updated
- Check out the SQL that was executed and expect to see
'FOR NO KEY UPDATE SKIP LOCKED'
- Now run `relation.touch_all`
- Expect the timestamps to be updated again, but the SQL should
not include 'SKIP LOCKED' lock type
Change-Id: If499982dc8fa368d312da7b8bcfc61a1f28b773b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286195
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jackson Howe <jackson.howe@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>