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

Fix the generated password not being idempotent in the ClickHouse provisioner #6271

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

begelundmuller
Copy link
Contributor

When editing the clickhouse.yaml file with keystroke-by-keystroke editing, provisioning calls can be rapidly cancelled and retried. This surfaced an idempotency issue where calling CREATE USER IF NOT EXISTS did not use the generated random password, causing the generated DSN to be invalid. This PR fixes the problem by leveraging ClickHouse's support for adding multiple passwords to one user.

@begelundmuller begelundmuller self-assigned this Dec 12, 2024
// When creating the user, the password assignment is not idempotent (if there are two concurrent invocations, we don't know which password was used).
// By adding the password separately, we ensure all passwords will work.
// NOTE: Requires ClickHouse 24.9 or later.
_, err = p.ch.ExecContext(ctx, fmt.Sprintf("ALTER USER %s ADD IDENTIFIED WITH sha256_password BY ?", user), password)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems risky, in a rare case of id collision, would it end up giving an existing project access to previously created DB ? However, in case of id collision we would have even bigger troubles..
Usually, locking on table name would be less prone to errors...

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