-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add offline schema updates for ClickHouse
- Some cleanup around issuing multiple SQL statements from a file - Create directory structure for storing schema updates modeled after CRDB up.sql files, but using integer versions, and move all existing SQL into version 2 - Add version 3, which fixes #4369, but does not apply it yet - Add methods in the client for listing, reading, and applying one or more updates to the oximeter database from the upgrade files - Add tests for upgrade application - Add `clickhouse-schema-updater` binary for running them on demand - Modify `oximeter-collector` to _not_ wipe / reinit the DB on startup if the version has change, but instead wait for the version to be equal to what it is compiled against. This relies on updates from the developer being applied before `oximeter` will continue.
- Loading branch information
Showing
16 changed files
with
2,341 additions
and
136 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ClickHouse schema files | ||
|
||
This directory contains the SQL files for different versions of the ClickHouse | ||
timeseries database used by `oximeter`. In general, schema are expected to be | ||
applied while the database is online, but no other clients exist. This is | ||
similar to the current situation for _offline upgrade_ we use when updating the | ||
main control plane database in CockroachDB. | ||
|
||
## Constraints, or why ClickHouse is weird | ||
|
||
While this tool is modeled after the mechanism for applying updates in | ||
CockroachDB, ClickHouse is a significantly different DBMS. There are no | ||
transactions; no unique primary keys; a single DB server can house both | ||
replicated and single-node tables. This means we need to be pretty careful when | ||
updating the schema. Changes must be idempotent, as with the CRDB schema, but at | ||
this point we do not support inserting or modifying data at all. | ||
|
||
Similar to the CRDB offline update tool, we assume no non-update modifications | ||
of the database are running concurrently. However, given ClickHouse's lack of | ||
transactions, we actually require that there are no writes of any kind. In | ||
practice, this means `oximeter` **must not** be running when this is called. | ||
Similarly, there must be only a single instance of this program at a time. | ||
|
||
To run this program: | ||
|
||
- Ensure the ClickHouse server is running, and grab its IP address; | ||
```bash | ||
$ pfexec zlogin oxz_clickhouse_e449eb80-3371-40a6-a316-d6e64b039357 'ipadm show-addr -o addrobj,addr | grep omicron6' | ||
oxControlService20/omicron6 fd00:1122:3344:101::e/64 | ||
``` | ||
- Log into the `oximeter` zone, `zlogin oxz_oximeter_<UUID>` | ||
- Ensure `oximeter` is _not_ running, e.g., `svcadm disable oximeter` | ||
- Run this tool, pointing it at the desired schema directory, e.g.: | ||
|
||
```bash | ||
# /opt/oxide/oximeter/bin/clickhouse-schema-updater \ | ||
--host <ADDR_FROM_ABOVE> \ | ||
--schema-dir /opt/oxide/oximeter/sql | ||
up VERSION | ||
``` |
Oops, something went wrong.