lib/mongoid/orderable/engine.rb in mongoid_orderable-6.0.0 vs lib/mongoid/orderable/engine.rb in mongoid_orderable-6.0.1

- old
+ new

@@ -178,14 +178,16 @@ if use_transactions && !embedded? && !Thread.current[ORDERABLE_TRANSACTION_KEY] Thread.current[ORDERABLE_TRANSACTION_KEY] = true retries = transaction_max_retries begin doc.class.with_session(causal_consistency: true) do |session| - session.start_transaction(read: { mode: :primary }, - read_concern: { level: 'majority' }, - write_concern: { w: 'majority' }) - yield - session.commit_transaction + doc.class.with(read: { mode: :primary }) do + session.start_transaction(read: { mode: :primary }, + read_concern: { level: 'majority' }, + write_concern: { w: 'majority' }) + yield + session.commit_transaction + end end rescue Mongo::Error::OperationFailure => e sleep(0.001) retries -= 1 retry if retries >= 0