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

PG::ConnectionBad: connection is closed after upgrading to rails 5.2 #570

Closed
asnad opened this issue Nov 14, 2018 · 2 comments
Closed

PG::ConnectionBad: connection is closed after upgrading to rails 5.2 #570

asnad opened this issue Nov 14, 2018 · 2 comments

Comments

@asnad
Copy link

asnad commented Nov 14, 2018

I have update rails version of my project form 4.2 to 5.2. Now I am getting following error on some of my tests randomly.
Counters::DefectDistributionContext execute group by defect should group counters by defect Failure/Error: DatabaseCleaner[:active_record].clean_with(:truncation)

   `ActiveRecord::StatementInvalid:
     PG::ConnectionBad: connection is closed: TRUNCATE TABLE "public"."alerts", "public"."gv_sub_equipments", "public"."machine_part_changes", "public"."settings", "public"."article_attachments", "public"."systematic_reject_machines", "public"."furnaces", "public"."attachments", "public"."defect_translations", "public"."gv_equipment_families", "public"."gv_equipments", "public"."gv_squads", "public"."article_check_specification_tolerances", "public"."gv_area_equipments", "public"."gv_areas", "public"."machine_downtimes", "public"."machine_groups", "public"."article_machine_part_settings", "public"."checks", "public"."comments", "public"."counters", "public"."customers", "public"."defect_groups", "public"."defects", "public"."delayed_jobs", "public"."job_specifications", "public"."machine_part_change_reasons", "public"."machine_part_translations", "public"."machine_parts", "public"."machine_type_group_machine_types", "public"."machine_type_groups", "public"."machine_types", "public"."messages", "public"."check_specification_priorities", "public"."check_specification_responsibility_areas", "public"."responsibility_areas", "public"."check_specification_machine_types", "public"."gv_components", "public"."gv_entries", "public"."gv_stop_reasons", "public"."gv_sub_equipment_components", "public"."jobs", "public"."lab_recipe_versions", "public"."lab_recipes", "public"."lines", "public"."mold_sets", "public"."check_groups", "public"."check_specifications", "public"."articles", "public"."packing_schemes", "public"."rails_admin_settings", "public"."check_batches", "public"."reasons", "public"."rejects", "public"."roles", "public"."shift_definitions", "public"."shifts", "public"."system_log_entries", "public"."task_status_changes", "public"."tasks", "public"."tresholds", "public"."user_responsibility_areas", "public"."users", "public"."users_roles", "public"."workstations", "public"."machines", "public"."systematic_rejects" RESTART IDENTITY CASCADE`

What should I do to fix this?

@Dantemss
Copy link

Dantemss commented May 28, 2019

Well try setting reaping_frequency: 0 for the test DB in database.yml (DON'T do this for Rails < 5.2 or you will see very degraded performance due to the reaper running in a loop). I had a similar issue in Rails 5.2 that was solved by changing that setting (records would disappear in the middle of a running example).

@smoyte
Copy link

smoyte commented Nov 4, 2019

@Dantemss Thank you so much for this fix! Saved my life!

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

No branches or pull requests

4 participants