Module: Evilution::ParallelDbWarning Private

Defined in:
lib/evilution/parallel_db_warning.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

EV-kdns / GH #817: nudge users running parallel jobs against SQLite to adopt the parallel_tests convention. WorkQueue sets TEST_ENV_NUMBER per worker, but that only helps if config/database.yml interpolates it into the database path. Without per-worker DB files, concurrent workers pile up on one SQLite file and surface ActiveRecord::StatementTimeout / SQLite3::BusyException — noise that MutationExecutor demotes to :neutral but still wastes wall-clock time.

Constant Summary collapse

DATABASE_YML =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

File.join("config", "database.yml")
MESSAGE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"[evilution] Parallel run (jobs > 1) detected with SQLite in " \
"config/database.yml. Interpolate ENV['TEST_ENV_NUMBER'] into the " \
"test database path for per-worker DB isolation. See README."

Class Method Summary collapse

Class Method Details

.reset!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/evilution/parallel_db_warning.rb', line 36

def reset!
  @mutex.synchronize { @warned_roots.clear }
end

.warn_if_sqlite_parallel(config, output: $stderr, root: Dir.pwd) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/evilution/parallel_db_warning.rb', line 23

def warn_if_sqlite_parallel(config, output: $stderr, root: Dir.pwd)
  return unless config.jobs > 1
  return unless sqlite_in_test_config?(root)

  @mutex.synchronize do
    return if @warned_roots[root]

    @warned_roots[root] = true
  end

  output.puts(MESSAGE)
end