Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix random CI failures #1495

Merged
merged 1 commit into from
Dec 27, 2019

Conversation

pablobm
Copy link
Collaborator

@pablobm pablobm commented Dec 14, 2019

We get frequent random CI failures with errors on feature specs, like
the following:

Failures:

  1) Search admin searches with an unknown filter
     Failure/Error: DatabaseCleaner.clean

     ActiveRecord::StatementInvalid:
       PG::TRDeadlockDetected: ERROR:  deadlock detected
       DETAIL:  Process 12270 waits for AccessExclusiveLock on relation 16412 of database 16386; blocked by process 12192.
       Process 12192 waits for AccessShareLock on relation 16400 of database 16386; blocked by process 12270.
       HINT:  See server log for query details.
       : TRUNCATE TABLE "public"."blog_posts", "public"."series", "public"."countries", "public"."log_entries", "public"."payments", "public"."product_meta_tags", "public"."customers", "public"."products", "public"."orders", "public"."line_items" RESTART IDENTITY CASCADE;
     # ./spec/support/database_cleaner.rb:19:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::TRDeadlockDetected:
     #   ERROR:  deadlock detected
     #   DETAIL:  Process 12270 waits for AccessExclusiveLock on relation 16412 of database 16386; blocked by process 12192.
     #   Process 12192 waits for AccessShareLock on relation 16400 of database 16386; blocked by process 12270.
     #   HINT:  See server log for query details.
     #   ./spec/support/database_cleaner.rb:19:in `block (2 levels) in <top (required)>'

Finished in 29.41 seconds (files took 3.65 seconds to load)
418 examples, 1 failure

This may or may not be related to DatabaseCleaner. As an attempt to
fix it, I'm trying this configuration, copied straight from their
documentation at https://github.com/DatabaseCleaner/database_cleaner/blob/v1.7.0/README.markdown

config.before(:each, type: :feature) do
# :rack_test driver's Rack app under test shares database connection
# with the specs, so continue to use transaction strategy for speed.
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [82/80]

the spec. The app's database connection would not be able to access
uncommitted transaction data setup over the spec's database connection.
MSG
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 14, 2019

I don't have permissions to re-run the build, so I'll be rebasing this as new commits are added to master, and logging here how the build went each time. (I could probably work around this, but I'm lazy now).

First push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from d170c73 to 6848bc3 Compare December 18, 2019 20:57
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 18, 2019

Second push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 6848bc3 to fca6f5d Compare December 18, 2019 21:12
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 18, 2019

Third push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from fca6f5d to 70bbebb Compare December 18, 2019 21:28
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 18, 2019

Fourth push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 70bbebb to 8b3cfc0 Compare December 18, 2019 21:49
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 19, 2019

Fifth push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 8b3cfc0 to 04ce1d1 Compare December 19, 2019 07:02
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 19, 2019

Sixth push: 🍏 pass 🍏

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 19, 2019

I'm not merging this yet because I'm not seeing other builds fail.

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 19, 2019

Actually no, here's a failure: https://circleci.com/gh/thoughtbot/administrate/5608 It's the Ruby 2.5 build for a50bbae

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 04ce1d1 to 51946e9 Compare December 19, 2019 07:28
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 19, 2019

Seventh push: 🍏 pass 🍏

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 51946e9 to cc4e534 Compare December 21, 2019 18:59
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 21, 2019

Eight push: 🍏 pass 🍏

(This is getting a bit silly).

@pablobm pablobm force-pushed the fix-random-ci-failures branch from cc4e534 to 8b26229 Compare December 25, 2019 10:23
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 25, 2019

Failure elsewhere: https://circleci.com/gh/thoughtbot/administrate/5637

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 25, 2019

Completely unexpected failure here! https://circleci.com/gh/thoughtbot/administrate/5639 However it's not to do with Postgres. Appears to be a different sort of fluke. I'll ignore it.

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 25, 2019

Another Postgres failure elsewhere! https://circleci.com/gh/thoughtbot/administrate/5636

@pablobm pablobm force-pushed the fix-random-ci-failures branch from 8b26229 to 2bcd73f Compare December 25, 2019 11:01
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 25, 2019

Another 🍏 pass 🍏

We get frequent random CI failures with errors on feature specs, like
the following:

```
Failures:

  1) Search admin searches with an unknown filter
     Failure/Error: DatabaseCleaner.clean

     ActiveRecord::StatementInvalid:
       PG::TRDeadlockDetected: ERROR:  deadlock detected
       DETAIL:  Process 12270 waits for AccessExclusiveLock on relation 16412 of database 16386; blocked by process 12192.
       Process 12192 waits for AccessShareLock on relation 16400 of database 16386; blocked by process 12270.
       HINT:  See server log for query details.
       : TRUNCATE TABLE "public"."blog_posts", "public"."series", "public"."countries", "public"."log_entries", "public"."payments", "public"."product_meta_tags", "public"."customers", "public"."products", "public"."orders", "public"."line_items" RESTART IDENTITY CASCADE;
     # ./spec/support/database_cleaner.rb:19:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::TRDeadlockDetected:
     #   ERROR:  deadlock detected
     #   DETAIL:  Process 12270 waits for AccessExclusiveLock on relation 16412 of database 16386; blocked by process 12192.
     #   Process 12192 waits for AccessShareLock on relation 16400 of database 16386; blocked by process 12270.
     #   HINT:  See server log for query details.
     #   ./spec/support/database_cleaner.rb:19:in `block (2 levels) in <top (required)>'

Finished in 29.41 seconds (files took 3.65 seconds to load)
418 examples, 1 failure
```

This may or may not be related to `DatabaseCleaner`. As an attempt to
fix it, I'm trying this configuration, copied straight from their
documentation at https://github.com/DatabaseCleaner/database_cleaner/blob/v1.7.0/README.markdown
@pablobm pablobm force-pushed the fix-random-ci-failures branch from 2bcd73f to 7855f74 Compare December 25, 2019 12:20
@pablobm
Copy link
Collaborator Author

pablobm commented Dec 25, 2019

Another Postgres-related failure elsewhere: https://circleci.com/gh/thoughtbot/administrate/5647

@nickcharlton
Copy link
Member

What do you think about this one now? Is it solving it enough that it might be worth merging and seeing when the problem comes up again?

@pablobm
Copy link
Collaborator Author

pablobm commented Dec 27, 2019

Some stats:

  • Without this change: ~64 builds, 5 failures related to Postgres deadlocks, no other failures.
  • With this change: ~24 builds, 0 failures related to Postgres deadlocks, 1 failure due to an unrelated issue.

So I guess without this change there's a Postgres deadlock every 12.8 builds, while there are none with this change. Is that statistically significant enough? No idea, but at least it doesn't seem to be making it worse.

Gah. Merging.

@pablobm pablobm merged commit 7180cd9 into thoughtbot:master Dec 27, 2019
@pablobm pablobm deleted the fix-random-ci-failures branch December 28, 2019 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants