Skip to content

fix docker_dev_setup db:drop failure#2603

Open
Whiteknight07 wants to merge 1 commit into
instructure:masterfrom
Whiteknight07:fix/docker-setup-check-running-containers
Open

fix docker_dev_setup db:drop failure#2603
Whiteknight07 wants to merge 1 commit into
instructure:masterfrom
Whiteknight07:fix/docker-setup-check-running-containers

Conversation

@Whiteknight07

Copy link
Copy Markdown

Summary

docker_dev_setup.sh fails with PG::ObjectInUse when
choosing DROP because app containers hold open database
connections that prevent db:drop from completing.

This fix:

  • Stops all app containers (web, jobs, etc.) before
    dropping, keeping only postgres and redis running
  • Uses rake db:drop via a one-shot container so Rails
    hooks (e.g. Redis flush) still execute
  • Reads database names from database.yml instead of
    hardcoding them
  • Adds an early prompt warning users about running
    containers at the start of setup

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

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
@CLAassistant

CLAassistant commented Apr 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

3 participants