temping icon indicating copy to clipboard operation
temping copied to clipboard

Random failure at CircleCI

Open camilohollanda opened this issue 10 years ago • 5 comments

I have been facing very frequent but still random errors at CircleCI:

1) Filterable#until returns only subjects until the requested date
     Failure/Error: 30.times { |i| subject.create(created_at: Time.current.change(day: i + 1)) }

     ActiveRecord::StatementInvalid:
       PG::UndefinedTable: ERROR:  relation "filterable_models" does not exist
       LINE 1: INSERT INTO "filterable_models" ("created_at", "updated_at")...
                           ^
       : INSERT INTO "filterable_models" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"
     # ./spec/models/concerns/filterable_spec.rb:85:in `block (4 levels) in <top (required)>'
     # ./spec/models/concerns/filterable_spec.rb:85:in `times'
     # ./spec/models/concerns/filterable_spec.rb:85:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedTable:
     #   ERROR:  relation "filterable_models" does not exist
     #   LINE 1: INSERT INTO "filterable_models" ("created_at", "updated_at")...
     #                       ^
     #   ./spec/models/concerns/filterable_spec.rb:85:in `block (4 levels) in <top (required)>'

I was not able to reproduce locally

camilohollanda avatar Jan 17 '16 18:01 camilohollanda

We ran into the same problem at my organisation.

@prem-prakash: Do you utilize parallelization (we use "parallel_tests") on CI? If not, do you use DatebaseCleaner and change your strategy between tests? we use :truncation for some tests, while using :transaction for most of them.

pierrebeitz avatar Feb 18 '16 11:02 pierrebeitz

@pierrebeitz yes we use parallelization, but not with parallel_tests, we use circleci native parallelization. Yes we use DatabaseCleaner but we do not change our strategy between tests. I hope this info can help in something

camilohollanda avatar Feb 23 '16 14:02 camilohollanda

the problem seems to be unrelated to parallelization.

in our case it had to do with the order of the specs. sometimes before the spec declaring

before(:all) do
  Temping.create :some_class do
    ...
  end
end

we have a capybara-spec running, which starts a webserver in a dedicated process. for just this spec we change the DatabaseCleaner-strategy from transaction to truncation which is changed back afterwards before the spec in question. Now somehow (whether it is the dedicated process or as i suspect some internal of DatabaseCleaner) the connection does not hold the table which has been created before anymore.

For now i go with the following workaround, which does not seem to be THAT slow:

  around(:each) do |example|
    Temping.create :some_class do
      ...
    end

    example.run

    Temping.teardown
  end

I hope this helps anyone to work their way to the real issue.

pierrebeitz avatar Feb 25 '16 14:02 pierrebeitz

Hi @prem-prakash, did it work with the suggestions made by @pierrebeitz?

kitop avatar Mar 06 '16 22:03 kitop

Hi, it worked for me! Thanks @pierrebeitz

bmurzeau avatar Mar 09 '16 21:03 bmurzeau