ClosureTree / with_advisory_lock

Advisory locking for ActiveRecord

Home Page:http://closuretree.github.io/with_advisory_lock/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many lock-closuretree--* files in project dir after spec run

dolzenko opened this issue · comments

I wonder if that is

  1. normal behaviour
  2. can be something like Dir.tmpdir used for lock storage?
  1. It is to be expected if you aren't using MySQL or Postgresql in your tests, and you aren't setting ENV['FLOCK_DIR'].
  2. In your spec_helper or minitest_helper, add a before and after block:
before do
  ENV['FLOCK_DIR'] = Dir.mktmpdir
  
end

after do
  FileUtils.remove_entry_secure ENV['FLOCK_DIR']
end

If you're using sqlite in your production code, make sure the same FLOCK_DIR value (that isn't a temporary directory) is set consistently across all ruby processes. I'll add a reference to this in the README.