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

Single node clickhouse init #6903

Draft
wants to merge 5 commits into
base: clickhouse-admin-smf-package-cleanup
Choose a base branch
from

Conversation

plotnick
Copy link
Contributor

@plotnick plotnick commented Oct 18, 2024

Depends on #6894, replaces #6878, fixes #6826 on the server side.

Adds a new Dropshot server, clickhouse-admin-single, analogous to clickhouse-admin-keeper and clickhouse-admin-server (which were split off from clickhouse-admin in #6837). Its sole purpose is to initialize the single-node ClickHouse database with the current Oximeter schema. We use a single in-memory lock (a tokio::sync::Mutex) to serialize initialization requests. Multi-node ClickHouse clusters will need something analogous as a follow-up.

Still needs testing. My a4x2 cluster is currently being uncooperative, and so this has not been through a successful "spin-up, expunge ClickHouse, regenerate" cycle. Also missing unit tests.

@plotnick plotnick changed the base branch from main to clickhouse-admin-smf-package-cleanup October 18, 2024 22:20
let admin_url = format!("http://{admin_addr}");
let log = opctx.log.new(slog::o!("admin_url" => admin_url.clone()));
let client = ClickhouseSingleClient::new(&admin_url, log.clone());
client.init_db().await.map(|_| ()).map_err(|e| {
Copy link
Contributor Author

@plotnick plotnick Oct 18, 2024

Choose a reason for hiding this comment

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

It's unclear to me if this is the right place to try to do this initialization, since we'll presumably have just spun up the server. It might be better to wait until the single-node server appears in an inventory collection, like the multi-node server does. OTOH, it shouldn't take long to start an uninitialized database, so we might be able to get away with a small retry loop and some longish timeouts, which seems significantly simpler. Opinions welcome.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could ping the server and wait for that to succeed before trying this. The init_db() call also returns an error indicating the server isn't available, so you might be able to just retry this call itself. The SQL it applies is idempotent.

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.

Need to initialize a fresh ClickHouse database without restarting Oximeter
3 participants