lib/lockbox/migrator.rb in lockbox-0.4.6 vs lib/lockbox/migrator.rb in lockbox-0.4.7
- old
+ new
@@ -114,9 +114,16 @@
end
yield records if records.any?
end
end
+ # there's a small chance for this process to read data,
+ # another process to update the data, and
+ # this process to write the now stale data
+ # this time window can be reduced with smaller batch sizes
+ # locking individual records could eliminate this
+ # one option is: relation.in_batches { |batch| batch.lock }
+ # which runs SELECT ... FOR UPDATE in Postgres
def migrate_records(records, fields:, blind_indexes:, restart:, rotate:)
# do computation outside of transaction
# especially expensive blind index computation
if rotate
records.each do |record|