fix docker_dev_setup db:drop failure#2603
Open
Whiteknight07 wants to merge 1 commit into
Open
Conversation
db:drop fails with PG::ObjectInUse when app containers hold open database connections. Fix by stopping all non-infrastructure containers (everything except postgres and redis) before dropping, then restarting them after. Uses rake db:drop via a one-shot container so Rails hooks (e.g. Redis flush) still run. Database names come from database.yml, not hardcoded values. Also adds an early check in docker_dev_setup.sh that warns users about running containers and offers to stop them before the setup begins. Test Plan: - Start Canvas containers (docker compose up -d) - Run bash script/docker_dev_setup.sh - Verify prompt shows running containers - Choose "y" to stop, confirm they stop - Run setup again with containers running - Choose "n" at early prompt to skip - When prompted, choose DROP for the database - Verify db:drop succeeds without ObjectInUse - Verify Redis state is flushed after drop - Verify setup completes successfully - Run with no containers, confirm no prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker_dev_setup.shfails withPG::ObjectInUsewhenchoosing DROP because app containers hold open database
connections that prevent
db:dropfrom completing.This fix:
dropping, keeping only postgres and redis running
rake db:dropvia a one-shot container so Railshooks (e.g. Redis flush) still execute
hardcoding them
containers at the start of setup
Test Plan
docker compose up -d)bash script/docker_dev_setup.sh