Skip to content

build/deploy: fix initdb scripts blocked when COCKROACH_USER unset#165785

Open
raajheshkannaa wants to merge 1 commit intocockroachdb:masterfrom
raajheshkannaa:fix/docker-entrypoint-initdb
Open

build/deploy: fix initdb scripts blocked when COCKROACH_USER unset#165785
raajheshkannaa wants to merge 1 commit intocockroachdb:masterfrom
raajheshkannaa:fix/docker-entrypoint-initdb

Conversation

@raajheshkannaa
Copy link

Summary

When COCKROACH_USER is not set, setup_db() calls run_sql_query with no -e flags, which opens an interactive SQL session that blocks the entrypoint indefinitely. This prevents scripts in /docker-entrypoint-initdb.d/ from running.

The fix moves the run_sql_query call inside the existing COCKROACH_USER guard so it only runs when there are GRANT statements to execute.

Fixes #110997

Changes

  • build/deploy/cockroach.sh: Moved run_sql_query call inside the [[ -n "$COCKROACH_USER" ]] conditional in setup_db()

Test plan

  • Start a container with start-single-node --insecure and a mounted init script, without setting COCKROACH_USER
  • Verify the init script executes and the database is created
  • Start with COCKROACH_USER set and verify GRANT statements still execute correctly

When COCKROACH_USER is not set, setup_db() called run_sql_query with
only the --certs-dir flag and no -e statements. This caused cockroach
sql to open an interactive session, blocking the entrypoint from ever
reaching process_init_files.

Move the run_sql_query call inside the existing COCKROACH_USER guard so
it only executes when there are actual GRANT statements to run.

Fixes cockroachdb#110997

Release note (bug fix): Docker entrypoint scripts in
/docker-entrypoint-initdb.d/ now execute correctly when the
COCKROACH_USER environment variable is not set.
@raajheshkannaa raajheshkannaa requested a review from a team as a code owner March 14, 2026 17:18
@trunk-io
Copy link
Contributor

trunk-io bot commented Mar 14, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@blathers-crl
Copy link

blathers-crl bot commented Mar 14, 2026

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added the O-community Originated from the community label Mar 14, 2026
@cockroachlabs-cla-agent
Copy link

cockroachlabs-cla-agent bot commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@aerfrei aerfrei added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker-entrypoint-initdb.d scripts don't run unless COCKROACH_USER is set

3 participants