title: Transactions isolation level and locking records, disable SELECT on records that are in running transaction
body: <p>Can I <strong>disable <code>SELECT</code></strong> on rows that are been used inside of a transaction? </p>
  
  <p>For example, rows in table <em>potatoes</em> are being destroyed in transaction 1, and it takes a long time to do so. In transaction 2, there is <code>SELECT*</code> on the <em>potatoes</em> table. I don't want to select those records that are being used in transaction 1.</p>
  
  <p>So, the result for <code>SELECT*</code> potatoes is without the records that are being used in transaction 1.</p>
  
  <p>Is <strong>isolation level serializable</strong> right fit for transaction 1, so transaction 2 can't select those rows?
  Or I need to lock those records with some <strong>lock mode</strong>?</p>
  
  <p>I'm trying to avoid flags in the database or Redis.</p>
  
  <p>Things I found:</p>
  
  <ul>
  <li><p><a href="https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-transaction" rel="nofollow noreferrer"><strong>Transaction levels</strong> in Rails</a></p></li>
  <li><p><a href="http://https://www.postgresql.org/docs/current/transaction-iso.html" rel="nofollow noreferrer">Transaction levels in PostgreSQL</a></p></li>
  <li><p><a href="https://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html" rel="nofollow noreferrer"><strong>Pessimistic locking</strong> in Rails</a></p></li>
  </ul>