-
-
Notifications
You must be signed in to change notification settings - Fork 61
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: Squash errors migrations #4854
Merged
Merged
Conversation
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
We rebuilt the errors table from scratch many years ago in the 0011_rebuild_errors migration. Let's squash everything before that now. It should save time and complexity for dev/ci/new installations.
This PR has a migration; here is the generated SQL -- start migrations
-- forward migration events : 0001_events_initial
-- end forward migration events : 0001_events_initial
-- backward migration events : 0001_events_initial
-- end backward migration events : 0001_events_initial
-- forward migration events : 0002_events_onpremise_compatibility
-- end forward migration events : 0002_events_onpremise_compatibility
-- backward migration events : 0002_events_onpremise_compatibility
-- end backward migration events : 0002_events_onpremise_compatibility
-- forward migration events : 0003_errors
-- end forward migration events : 0003_errors
-- backward migration events : 0003_errors
-- end backward migration events : 0003_errors
-- forward migration events : 0004_errors_onpremise_compatibility
-- end forward migration events : 0004_errors_onpremise_compatibility
-- backward migration events : 0004_errors_onpremise_compatibility
-- end backward migration events : 0004_errors_onpremise_compatibility
-- forward migration events : 0005_events_tags_hash_map
-- end forward migration events : 0005_events_tags_hash_map
-- backward migration events : 0005_events_tags_hash_map
-- end backward migration events : 0005_events_tags_hash_map
-- forward migration events : 0006_errors_tags_hash_map
-- end forward migration events : 0006_errors_tags_hash_map
-- backward migration events : 0006_errors_tags_hash_map
-- end backward migration events : 0006_errors_tags_hash_map
-- forward migration events : 0009_errors_add_http_fields
-- end forward migration events : 0009_errors_add_http_fields
-- backward migration events : 0009_errors_add_http_fields
-- end backward migration events : 0009_errors_add_http_fields
-- forward migration events : 0011_rebuild_errors
Local op: CREATE TABLE IF NOT EXISTS errors_local (project_id UInt64, timestamp DateTime, event_id UUID CODEC (NONE), platform LowCardinality(String), environment LowCardinality(Nullable(String)), release LowCardinality(Nullable(String)), dist LowCardinality(Nullable(String)), ip_address_v4 Nullable(IPv4), ip_address_v6 Nullable(IPv6), user String DEFAULT '', user_hash UInt64 MATERIALIZED cityHash64(user), user_id Nullable(String), user_name Nullable(String), user_email Nullable(String), sdk_name LowCardinality(Nullable(String)), sdk_version LowCardinality(Nullable(String)), http_method LowCardinality(Nullable(String)), http_referer Nullable(String), tags Nested(key String, value String), contexts Nested(key String, value String), transaction_name LowCardinality(String) DEFAULT '', transaction_hash UInt64 MATERIALIZED cityHash64(transaction_name), span_id Nullable(UInt64), trace_id Nullable(UUID), partition UInt16, offset UInt64 CODEC (DoubleDelta, LZ4), message_timestamp DateTime, retention_days UInt16, deleted UInt8, group_id UInt64, primary_hash UUID, received DateTime, message String, title String, culprit String, level LowCardinality(String), location Nullable(String), version LowCardinality(Nullable(String)), type LowCardinality(String), exception_stacks Nested(type Nullable(String), value Nullable(String), mechanism_type Nullable(String), mechanism_handled Nullable(UInt8)), exception_frames Nested(abs_path Nullable(String), colno Nullable(UInt32), filename Nullable(String), function Nullable(String), lineno Nullable(UInt32), in_app Nullable(UInt8), package Nullable(String), module Nullable(String), stack_level Nullable(UInt16)), sdk_integrations Array(String), modules Nested(name String, version String)) ENGINE ReplicatedReplacingMergeTree('/clickhouse/tables/events/{shard}/default/errors_local', '{replica}', deleted) ORDER BY (project_id, toStartOfDay(timestamp), primary_hash, cityHash64(event_id)) PARTITION BY (retention_days, toMonday(timestamp)) SAMPLE BY cityHash64(event_id) TTL timestamp + toIntervalDay(retention_days) SETTINGS index_granularity=8192;
Local op: ALTER TABLE errors_local ADD COLUMN IF NOT EXISTS _tags_hash_map Array(UInt64) MATERIALIZED arrayMap((k, v) -> cityHash64(concat(replaceRegexpAll(k, '(\\=|\\\\)', '\\\\\\1'), '=', v)), tags.key, tags.value) AFTER tags;
Distributed op: CREATE TABLE IF NOT EXISTS errors_dist (project_id UInt64, timestamp DateTime, event_id UUID CODEC (NONE), platform LowCardinality(String), environment LowCardinality(Nullable(String)), release LowCardinality(Nullable(String)), dist LowCardinality(Nullable(String)), ip_address_v4 Nullable(IPv4), ip_address_v6 Nullable(IPv6), user String DEFAULT '', user_hash UInt64 MATERIALIZED cityHash64(user), user_id Nullable(String), user_name Nullable(String), user_email Nullable(String), sdk_name LowCardinality(Nullable(String)), sdk_version LowCardinality(Nullable(String)), http_method LowCardinality(Nullable(String)), http_referer Nullable(String), tags Nested(key String, value String), contexts Nested(key String, value String), transaction_name LowCardinality(String) DEFAULT '', transaction_hash UInt64 MATERIALIZED cityHash64(transaction_name), span_id Nullable(UInt64), trace_id Nullable(UUID), partition UInt16, offset UInt64 CODEC (DoubleDelta, LZ4), message_timestamp DateTime, retention_days UInt16, deleted UInt8, group_id UInt64, primary_hash UUID, received DateTime, message String, title String, culprit String, level LowCardinality(String), location Nullable(String), version LowCardinality(Nullable(String)), type LowCardinality(String), exception_stacks Nested(type Nullable(String), value Nullable(String), mechanism_type Nullable(String), mechanism_handled Nullable(UInt8)), exception_frames Nested(abs_path Nullable(String), colno Nullable(UInt32), filename Nullable(String), function Nullable(String), lineno Nullable(UInt32), in_app Nullable(UInt8), package Nullable(String), module Nullable(String), stack_level Nullable(UInt16)), sdk_integrations Array(String), modules Nested(name String, version String)) ENGINE Distributed(cluster_one_sh, default, errors_local, cityHash64(event_id));
Distributed op: ALTER TABLE errors_dist ADD COLUMN IF NOT EXISTS _tags_hash_map Array(UInt64) MATERIALIZED arrayMap((k, v) -> cityHash64(concat(replaceRegexpAll(k, '(\\=|\\\\)', '\\\\\\1'), '=', v)), tags.key, tags.value) AFTER tags;
Distributed op: CREATE TABLE IF NOT EXISTS errors_dist_ro (project_id UInt64, timestamp DateTime, event_id UUID CODEC (NONE), platform LowCardinality(String), environment LowCardinality(Nullable(String)), release LowCardinality(Nullable(String)), dist LowCardinality(Nullable(String)), ip_address_v4 Nullable(IPv4), ip_address_v6 Nullable(IPv6), user String DEFAULT '', user_hash UInt64 MATERIALIZED cityHash64(user), user_id Nullable(String), user_name Nullable(String), user_email Nullable(String), sdk_name LowCardinality(Nullable(String)), sdk_version LowCardinality(Nullable(String)), http_method LowCardinality(Nullable(String)), http_referer Nullable(String), tags Nested(key String, value String), contexts Nested(key String, value String), transaction_name LowCardinality(String) DEFAULT '', transaction_hash UInt64 MATERIALIZED cityHash64(transaction_name), span_id Nullable(UInt64), trace_id Nullable(UUID), partition UInt16, offset UInt64 CODEC (DoubleDelta, LZ4), message_timestamp DateTime, retention_days UInt16, deleted UInt8, group_id UInt64, primary_hash UUID, received DateTime, message String, title String, culprit String, level LowCardinality(String), location Nullable(String), version LowCardinality(Nullable(String)), type LowCardinality(String), exception_stacks Nested(type Nullable(String), value Nullable(String), mechanism_type Nullable(String), mechanism_handled Nullable(UInt8)), exception_frames Nested(abs_path Nullable(String), colno Nullable(UInt32), filename Nullable(String), function Nullable(String), lineno Nullable(UInt32), in_app Nullable(UInt8), package Nullable(String), module Nullable(String), stack_level Nullable(UInt16)), sdk_integrations Array(String), modules Nested(name String, version String)) ENGINE Distributed(cluster_one_sh, default, errors_local, cityHash64(event_id));
-- end forward migration events : 0011_rebuild_errors
-- backward migration events : 0011_rebuild_errors
Distributed op: DROP TABLE IF EXISTS errors_dist;
Distributed op: DROP TABLE IF EXISTS errors_dist;
Local op: DROP TABLE IF EXISTS errors_local;
-- end backward migration events : 0011_rebuild_errors
-- forward migration events : 0013_errors_add_hierarchical_hashes
Local op: ALTER TABLE errors_local ADD COLUMN IF NOT EXISTS hierarchical_hashes Array(UUID) AFTER primary_hash;
Distributed op: ALTER TABLE errors_dist ADD COLUMN IF NOT EXISTS hierarchical_hashes Array(UUID) AFTER primary_hash;
-- end forward migration events : 0013_errors_add_hierarchical_hashes
-- backward migration events : 0013_errors_add_hierarchical_hashes
Distributed op: ALTER TABLE errors_dist DROP COLUMN IF EXISTS hierarchical_hashes;
Local op: ALTER TABLE errors_local DROP COLUMN IF EXISTS hierarchical_hashes;
-- end backward migration events : 0013_errors_add_hierarchical_hashes
-- forward migration events : 0014_backfill_errors
-- end forward migration events : 0014_backfill_errors
-- backward migration events : 0014_backfill_errors
-- end backward migration events : 0014_backfill_errors
-- forward migration events : 0015_truncate_events
-- end forward migration events : 0015_truncate_events
-- backward migration events : 0015_truncate_events
-- end backward migration events : 0015_truncate_events
-- forward migration events : 0016_drop_legacy_events
-- end forward migration events : 0016_drop_legacy_events
-- backward migration events : 0016_drop_legacy_events
-- end backward migration events : 0016_drop_legacy_events |
dbanda
approved these changes
Oct 13, 2023
lynnagara
added
the
skip-check-migrations
skip checking the migration CI for coupled changes
label
Oct 13, 2023
evanh
approved these changes
Oct 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We rebuilt the errors table from scratch many years ago in the 0011_rebuild_errors migration. Let's squash everything before that now.
It should save time and complexity for dev/ci/new installations.