MySQL write locks also prevent reads
Oct 17, 2013Locking a table with
table_name = 'widgets'
ActiveRecord::Base.connection.execute("LOCK TABLES #{table_name} WRITE")
ensures that only the current connection can access that table. Other connections cannot even read from this table while it is locked!