User: Bypass repeatable-read when creating an actor_id
When MySQL is using repeatable-read transaction isolation (which is the
default), the following sequence of events can occur:
- Request A: Begin a transaction.
- Request A: Try to select the actor ID for a user. Find no rows.
- Request B: Insert an actor ID for that user.
- Request A: Try to insert an actor ID for the user. Fails because one exists.
- Request A: Try to select the actor ID that must exist. Fail because of the snapshot created at step 2.
In MySQL we can avoid this issue at step #5 by using a locking select
(FOR UPDATE or LOCK IN SHARE MODE), so let's do that.