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

feat(connector): single events table across namespaces #410

Merged
merged 10 commits into from
Nov 13, 2023

Conversation

hekike
Copy link
Contributor

@hekike hekike commented Nov 13, 2023

Single events table across namespaces.

ClickHouse recommendation is only to have one insert per second.
See: ClickHouse/ClickHouse#34170

This PR batches all inserts into a single monthly partition across all namespaces as:

A thumb rule , the insert should insert into only one partition. Number of inserts is up to 1 insert per second PER INSTANCE. (NOT PER TABLE).

This PR stores all namespace events into a single table partitioned by month:

You should never use too granular partitioning. Don't partition your data by client identifiers or names (instead, make client identifier or name the first column in the ORDER BY expression).

Breaking Change:

This PR changes the query behind materialized views moving the meters.
As altering the query of MaterializedViews backed by AggregatingMergeTree is currently unimplemented in ClickHouse, there is no straightforward path forward to migrate.

We recommend creating new meters. Old meters remain queriable.

Migration:

If you MUST migrate follow:

As pre-1.0.0 release, this breaking change requires manual migration.

1. Stop sink-worker or Kafka Connect

This stop ingestion to the ClickHouse DB. Events will queue up in Kafka topic, so you won't lose new data just delay meter aggregates.

2. Update Events Table in ClickHouse

Run the following command to update your ClickHouse DB:

curl -u default:default -d "RENAME DATABASE openmeter.om_default_events TO openmeter.om_events" -X POST http://localhost:8123
curl -u default:default -d "ALTER TABLE openmeter.om_events ADD COLUMN namespace String FIRST" -X POST http://localhost:8123
curl -u default:default -d "ALTER TABLE openmeter.om_events UPDATE namespace = 'default' WHERE empty(namespace);" -X POST http://localhost:8123

3. Start OpenMeter With Recreate Config

Add the following to your config.yaml temporary.

aggregation:
  createOrReplaceMeter: true
  populateMeter: true

Starting OpenMeter with these settings can take longer.

4. Restart sink-worker

Restart sink-worker and remove createOrReplaceMeter and populateMeter from your config.

If you are stuck with migration, reach out on our Discord, and we will assist you.

@hekike hekike added area/processor release-note/breaking-change Release note: Breaking Changes labels Nov 13, 2023
@hekike hekike marked this pull request as ready for review November 13, 2023 01:27
@hekike hekike changed the base branch from feat/invalid-events to main November 13, 2023 17:50
@hekike hekike merged commit 2f48810 into main Nov 13, 2023
12 checks passed
@hekike hekike deleted the feat/unified-events-table branch November 13, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants