18

Is there a good tutorial/guide/blog post/book chapter/screencast/etc that attempts to comprehensively cover everything having to do with locks, transactions, and isolation levels in ActiveRecord? (preferably relevant to Rails 4.0)

There's a brief section in the guides, and of course some API docs, but it's a really important and (for me) hard-to-understand domain, and it's my first time trying to take data integrity seriously in my Rails app. I'd like to get a good understanding so I can do it properly.

List of Known Resources

odigity
  • 7,568
  • 4
  • 37
  • 51
  • i would recommend looking for guide/book on mysql transactions and see how it is recommended to use. Then you can write ruby code that will utilize those recommendations. – Iuri G. Jan 16 '14 at 16:08

2 Answers2

11

I would check out Chapter 5 of The Rails 3 Way for now, particularly Section 5.5 on Database Locking. I would also look at the ActiveRecord::Locking source, ActiveRecord::Transactions source, and the transaction_isolation test case as the code is very readable and if you're going to need some down in the weeds answers, it's there in the code!

Marc
  • 4,546
  • 2
  • 29
  • 45
3

I found Differences between transactions and locking on Makandropedia a pretty useful starting point to learn the difference between transactions and locks.

lulalala
  • 17,572
  • 15
  • 110
  • 169
  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – eirikir Sep 28 '15 at 17:14
  • If link dies we can replace it with archived copy. I feel most of it is essential. – lulalala Dec 21 '16 at 01:08
  • This article refers to a method `Lock.acquire()` but that does not seem to be referenced anywhere else, let alone in Rails docs. – Jason Galuten May 30 '18 at 23:37