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

cli/start: sdnotify socket listen chokes if $PWD is too long #76904

Closed
steven-hubbard opened this issue Feb 22, 2022 · 1 comment · Fixed by #84532
Closed

cli/start: sdnotify socket listen chokes if $PWD is too long #76904

steven-hubbard opened this issue Feb 22, 2022 · 1 comment · Fixed by #84532
Assignees
Labels
A-cli-server CLI commands that pertain to CockroachDB server processes C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-server-and-security DB Server & Security

Comments

@steven-hubbard
Copy link
Contributor

steven-hubbard commented Feb 22, 2022

We create cockroach single node instances in tests, to write integration-style tests against. Our builds happen in sandboxes; in particular TMPDIR is typically set to a very long path.

We don't want to hit disk so we point the cockroach node at a ram disk. We pass --temp-dir and --socket-dir ; something in cockroach ignores these and attempts to create a unix socket in $TMPDIR. This fails because the maximum length of a unix socket name is 108 chars, and our sandbox's tmp dir name takes the length over that.

Example, doing things straight on the command line. (This is on EL 7.)

Set up directories:

~ $ mkdir $HOME/this-is-a-very-long-directory-name-the-point-is-to-be-more-than-one-hundred-and-eight-characters

~ $ export TMPDIR=$HOME/this-is-a-very-long-directory-name-the-point-is-to-be-more-than-one-hundred-and-eight-characters

~ $ mkdir ~/local/sensible-length-path

~ $ export BASE=$HOME/sensible-length-path

~ $ mkdir -p $BASE/{tmp,store,socket}

Try to start cockroach

~ $ cockroach version
Build Tag:        v21.2.5
Build Time:       2022/02/07 21:01:07
Distribution:     CCL
Platform:         linux amd64 (x86_64-unknown-linux-gnu)
Go Version:       go1.16.6
C Compiler:       gcc 6.5.0
Build Commit ID:  5afb632f77eee9f09f2adfa2943e1979ec4ebedf
Build Type:       release

~ $ cockroach start-single-node --insecure --background --listen-addr=localhost:9090 --http-addr=localhost:9091 --pid-file=$BASE/pid --store=$BASE/store --temp-dir=$BASE/tmp --socket-dir=$BASE/socket

E220211 05:05:00.202740 1 1@cli/clierror/check.go:35  [-] 1  ERROR: cannot dial server.
E220211 05:05:00.202740 1 1@cli/clierror/check.go:35  [-] 1 +Is the server running?
E220211 05:05:00.202740 1 1@cli/clierror/check.go:35  [-] 1 +If the server is running, check --host client-side and --advertise server-side.
E220211 05:05:00.202740 1 1@cli/clierror/check.go:35  [-] 1 +listen unixgram /home/foo/this-is-a-very-long-directory-name-the-point-is-to-be-more-than-one-hundred-and-twenty-three-characters/sdnotify058488223/notify.sock: bind: invalid argument
ERROR: cannot dial server.
Is the server running?
If the server is running, check --host client-side and --advertise server-side.

listen unixgram /home/foo/this-is-a-very-long-directory-name-the-point-is-to-be-more-than-one-hundred-and-twenty-three-characters/sdnotify058488223/notify.sock: bind: invalid argument
Failed running "start-single-node"
EXIT STATUS 1

Override TMPDIR to something reasonable and cockroach works:

~ $ export TMPDIR=$BASE/tmp

~ $ cockroach start-single-node --insecure --background --listen-addr=localhost:9090 --http-addr=localhost:9091 --pid-file=$BASE/pid --store=$BASE/store --temp-dir=$BASE/tmp --socket-dir=$BASE/socket
*
* WARNING: ALL SECURITY CONTROLS HAVE BEEN DISABLED!
*
* This mode is intended for non-production testing only.
*
* In this mode:
* - Your cluster is open to any client that can access localhost.
* - Intruders with access to your machine or network can observe client-server traffic.
* - Intruders can log in without password and read or write any data in the cluster.
* - Intruders can consume all your server's resources and cause unavailability.
*
*
* INFO: To start a secure server without mandating TLS for clients,
* consider --accept-sql-without-tls instead. For other options, see:
*
* - https://go.crdb.dev/issue-v/53404/v21.2
* - https://www.cockroachlabs.com/docs/v21.2/secure-a-cluster.html
*

This looks like something internal is preferring env variables to explicitly passed flags, which I think is a bug.

Jira issue: CRDB-13317

@steven-hubbard steven-hubbard added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Feb 22, 2022
@knz knz self-assigned this Apr 30, 2022
@knz knz changed the title CockroachDB appears to ignore the --temp-dir flag in favor of environment variables cli/start: sdnotify socket listen chokes if $PWD is too long Apr 30, 2022
@knz knz added the A-cli-server CLI commands that pertain to CockroachDB server processes label Apr 30, 2022
@blathers-crl blathers-crl bot added the T-server-and-security DB Server & Security label Apr 30, 2022
@knz
Copy link
Contributor

knz commented Apr 30, 2022

@lunevalex with the current responsibility split, this issue would fall under KV right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli-server CLI commands that pertain to CockroachDB server processes C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-server-and-security DB Server & Security
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants