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

set the SLOW_LOG_FILE in the startup script #307

Merged
merged 3 commits into from
Mar 14, 2019

Conversation

gregwebs
Copy link
Contributor

Relying on go code to set an env variable is brittle, at least brittle enough that I ran into this. We can make sure it is set in the script itself.

Bash is painful, this is my standard technique for making sure variables are set to a default.

@aylei

I tested this as fixing the issue.

@gregwebs
Copy link
Contributor Author

#295 set this in go code.

@aylei
Copy link
Contributor

aylei commented Mar 12, 2019

Thank you for your guidance @gregwebs !
&
LGTM

@gregwebs
Copy link
Contributor Author

/run-e2e-tests

@gregwebs gregwebs requested a review from tennix March 12, 2019 17:21
Copy link
Member

@tennix tennix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gregwebs
Copy link
Contributor Author

/run-e2e-tests

@@ -34,6 +34,7 @@ then
ARGS="${ARGS} --enable-binlog=true"
fi

SLOW_LOG_FILE=${SLOW_LOG_FILE:-""}
if [[ ! -z "${SLOW_LOG_FILE}" ]]
then
ARGS="${ARGS} --log-slow-query=${SLOW_LOG_FILE:-}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have ${SLOW_LOG_FILE:-} after setting it on line 37 and checking it on line 38?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 38 it will be undefined. The purpose of line 37 is just to define it and set a default value if it is not defined. It is a little verbose and obscure as bash is, but I think this idiom is easy to get used to and understand whereas the other ones are trickier. And overall it is much safer to use these techniques and have undefined variables be an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so I think you are more directly asking about :-. That allows for the variable to be unset and not throw an undefined variable error.

${parameter:-word}
    If parameter is unset or null, the expansion of word is substituted. 
    Otherwise, the value of parameter is substituted.

@tennix tennix merged commit 2addf4d into pingcap:master Mar 14, 2019
@tennix tennix deleted the startup-script-set-SLOW_LOG_FILE branch March 14, 2019 06:19
yahonda pushed a commit that referenced this pull request Dec 27, 2021
* .github: add workflow to auto assign to projects

* Update assign-to-project.yml
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