Prevent deadlock in context_modules#update_item
Prevent deadlock in context_modules#update_item

In context_modules#update_item, we frequently run into deadlocks due
to these two transactions:
 txn 1: content_tag.save
 - updates content_tags table
 - after_save callback updates some content table (like wiki_pages,
   for instance)

 txn 2: content_tag.update_asset_name!
 - updates the same content table (again, like wiki_pages)
 - updates the same info in content_tags table

Because the order of those updates isn't normalized, we see lots of
deadlocks. This commit reverses the order of queries in txn 1 by
updating the content table in a before_save callback. The effect is
the same; both tables get updated by the end of the transaction and
data integrity is insured since the entire transaction is rolled back
if an issue occurs with either query.

closes LS-2928
flag = none

Test plan:
 - Visit a course's modules page and edit the names of several module
   items (different content types)
 - Expect everything to work normally

Change-Id: Ib971871cfa0f035de5cedfacbb327aba0a2a666d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/283122
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Reviewed-by: Jeremy Stanley <b3f594e10a9edcf5413cf1190121d45078c62290@instructure.com>
QA-Review: Eric Saupe <e7287cf05ae62bc45889f17a9d34b8fae8d5afd1@instructure.com>
Product-Review: Jackson Howe <318c10a818c1b1f2ec50cdcb1827b2c6c5ebd7dc@instructure.com>

instructure/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,instructure/canvas-lms