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: Squash errors migrations #4854

Merged
merged 10 commits into from
Oct 19, 2023
Merged

feat: Squash errors migrations #4854

merged 10 commits into from
Oct 19, 2023

Conversation

lynnagara
Copy link
Member

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.

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.
@lynnagara lynnagara requested a review from a team as a code owner October 13, 2023 21:30
@github-actions
Copy link

github-actions bot commented Oct 13, 2023

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

@lynnagara lynnagara added the skip-check-migrations skip checking the migration CI for coupled changes label Oct 13, 2023
@lynnagara lynnagara merged commit 73cd686 into master Oct 19, 2023
26 of 29 checks passed
@lynnagara lynnagara deleted the squash-errors-migrations branch October 19, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrations skip-check-migrations skip checking the migration CI for coupled changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants