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

cleanup(smart_autocomplte): remove experimental materialized views from EAP spans #6917

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

volokluev
Copy link
Member

These only existed to get some testing data, which we now have. These tables are no longer useful but are taking up load and space

@volokluev volokluev requested review from a team as code owners February 26, 2025 19:46
Copy link

github-actions bot commented Feb 26, 2025

This PR has a migration; here is the generated SQL for ./snuba/migrations/groups.py ()

-- start migrations

-- forward migration events_analytics_platform : 0029_remove_smart_autocomplete_experimental
Local op: DROP TABLE IF EXISTS eap_trace_item_attrs_mv;
Local op: DROP TABLE IF EXISTS eap_trace_item_attrs_local;
Distributed op: DROP TABLE IF EXISTS eap_trace_item_attrs_dist;
-- end forward migration events_analytics_platform : 0029_remove_smart_autocomplete_experimental




-- backward migration events_analytics_platform : 0029_remove_smart_autocomplete_experimental
Local op: CREATE TABLE IF NOT EXISTS eap_trace_item_attrs_local (project_id UInt64, item_type String, date Date CODEC (DoubleDelta, ZSTD(1)), retention_days UInt16, attrs_string Map(String, String), attrs_bool Array(String), attrs_int64 Array(String), attrs_float64 Array(String), key_val_hash UInt64) ENGINE ReplicatedReplacingMergeTree('/clickhouse/tables/events_analytics_platform/{shard}/default/eap_trace_item_attrs_local', '{replica}') PRIMARY KEY (project_id, date, key_val_hash) ORDER BY (project_id, date, key_val_hash) PARTITION BY (retention_days, toMonday(date)) TTL date + toIntervalDay(retention_days);
Distributed op: CREATE TABLE IF NOT EXISTS eap_trace_item_attrs_dist (project_id UInt64, item_type String, date Date CODEC (DoubleDelta, ZSTD(1)), retention_days UInt16, attrs_string Map(String, String), attrs_bool Array(String), attrs_int64 Array(String), attrs_float64 Array(String), key_val_hash UInt64) ENGINE Distributed(`cluster_one_sh`, default, eap_trace_item_attrs_local);
Local op: CREATE MATERIALIZED VIEW IF NOT EXISTS eap_trace_item_attrs_mv TO eap_trace_item_attrs_local (project_id UInt64, item_type String, date Date CODEC (DoubleDelta, ZSTD(1)), retention_days UInt16, attrs_string Map(String, String), attrs_bool Array(String), attrs_int64 Array(String), attrs_float64 Array(String), key_val_hash UInt64) AS 
SELECT
    project_id,
    'span',
    toDate(_sort_timestamp) AS date,
    retention_days as retention_days,
    mapConcat(attr_str_0, attr_str_1, attr_str_2, attr_str_3, attr_str_4, attr_str_5, attr_str_6, attr_str_7, attr_str_8, attr_str_9, attr_str_10, attr_str_11, attr_str_12, attr_str_13, attr_str_14, attr_str_15, attr_str_16, attr_str_17, attr_str_18, attr_str_19) AS attrs_string, -- `attrs_string` Map(String, String),
    array() AS attrs_bool, -- bool
    array() AS attrs_int64, -- int64
    arrayConcat(mapKeys(attr_num_0), mapKeys(attr_num_1), mapKeys(attr_num_2), mapKeys(attr_num_3), mapKeys(attr_num_4), mapKeys(attr_num_5), mapKeys(attr_num_6), mapKeys(attr_num_7), mapKeys(attr_num_8), mapKeys(attr_num_9), mapKeys(attr_num_10), mapKeys(attr_num_11), mapKeys(attr_num_12), mapKeys(attr_num_13), mapKeys(attr_num_14), mapKeys(attr_num_15), mapKeys(attr_num_16), mapKeys(attr_num_17), mapKeys(attr_num_18), mapKeys(attr_num_19)) AS attrs_float64, -- float
    -- a hash of all the attribute key,val pairs of the item in sorted order
    -- this lets us deduplicate rows with merges
    cityHash64(mapSort(
        mapConcat(
            mapApply((k, v) -> (k, ''), attr_num_0),
            mapApply((k, v) -> (k, ''), attr_num_1),
            mapApply((k, v) -> (k, ''), attr_num_2),
            mapApply((k, v) -> (k, ''), attr_num_3),
            mapApply((k, v) -> (k, ''), attr_num_4),
            mapApply((k, v) -> (k, ''), attr_num_5),
            mapApply((k, v) -> (k, ''), attr_num_6),
            mapApply((k, v) -> (k, ''), attr_num_7),
            mapApply((k, v) -> (k, ''), attr_num_8),
            mapApply((k, v) -> (k, ''), attr_num_9),
            mapApply((k, v) -> (k, ''), attr_num_10),
            mapApply((k, v) -> (k, ''), attr_num_11),
            mapApply((k, v) -> (k, ''), attr_num_12),
            mapApply((k, v) -> (k, ''), attr_num_13),
            mapApply((k, v) -> (k, ''), attr_num_14),
            mapApply((k, v) -> (k, ''), attr_num_15),
            mapApply((k, v) -> (k, ''), attr_num_16),
            mapApply((k, v) -> (k, ''), attr_num_17),
            mapApply((k, v) -> (k, ''), attr_num_18),
            mapApply((k, v) -> (k, ''), attr_num_19),
            attr_str_0,
            attr_str_1,
            attr_str_2,
            attr_str_3,
            attr_str_4,
            attr_str_5,
            attr_str_6,
            attr_str_7,
            attr_str_8,
            attr_str_9,
            attr_str_10,
            attr_str_11,
            attr_str_12,
            attr_str_13,
            attr_str_14,
            attr_str_15,
            attr_str_16,
            attr_str_17,
            attr_str_18,
            attr_str_19
        )
    )) AS key_val_hash
FROM eap_spans_2_local


;
-- end backward migration events_analytics_platform : 0029_remove_smart_autocomplete_experimental

Copy link

codecov bot commented Feb 26, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1292 1 1291 9
View the top 1 failed test(s) by shortest run time
tests.migrations.test_runner::test_reverse_all
Stack Traces | 9.5s run time
Traceback (most recent call last):
  File ".../snuba/clickhouse/native.py", line 206, in execute
    result_data = query_execute()
                  ^^^^^^^^^^^^^^^
  File ".../snuba/clickhouse/native.py", line 189, in query_execute
    return conn.execute(  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.............../site-packages/clickhouse_driver/client.py", line 382, in execute
    rv = self.process_ordinary_query(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.............../site-packages/clickhouse_driver/client.py", line 580, in process_ordinary_query
    return self.receive_result(with_column_types=with_column_types,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.../sentry_sdk/integrations/clickhouse_driver.py", line 112, in _inner_end
    res = f(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.............../site-packages/clickhouse_driver/client.py", line 212, in receive_result
    return result.get_result()
           ^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.../site-packages/clickhouse_driver/result.py", line 50, in get_result
    for packet in self.packet_generator:
  File ".../local/lib/python3.11.............../site-packages/clickhouse_driver/client.py", line 228, in packet_generator
    packet = self.receive_packet()
             ^^^^^^^^^^^^^^^^^^^^^
  File ".../local/lib/python3.11.............../site-packages/clickhouse_driver/client.py", line 245, in receive_packet
    raise packet.exception
clickhouse_driver.errors.ServerException: Code: 60.
DB::Exception: Could not find table: eap_trace_item_attrs_local. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c61ff37 in ......................................................................../usr/bin/clickhouse
1. DB::Exception::Exception<String&>(int, FormatStringHelperImpl<std::type_identity<String&>::type>, String&) @ 0x00000000074a968d in ......................................................................../usr/bin/clickhouse
2. DB::InterpreterAlterQuery::executeToTable(DB::ASTAlterQuery const&) @ 0x0000000011d8bba9 in ......................................................................../usr/bin/clickhouse
3. DB::InterpreterAlterQuery::execute() @ 0x0000000011d88230 in ......................................................................../usr/bin/clickhouse
4. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x00000000122bfe15 in ......................................................................../usr/bin/clickhouse
5. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x00000000122bb5b5 in ......................................................................../usr/bin/clickhouse
6. DB::TCPHandler::runImpl() @ 0x0000000013137519 in ......................................................................../usr/bin/clickhouse
7. DB::TCPHandler::run() @ 0x00000000131498f9 in ......................................................................../usr/bin/clickhouse
8. Poco::Net::TCPServerConnection::start() @ 0x0000000015b42834 in ......................................................................../usr/bin/clickhouse
9. Poco::Net::TCPServerDispatcher::run() @ 0x0000000015b43a31 in ......................................................................../usr/bin/clickhouse
10. Poco::PooledThread::run() @ 0x0000000015c7a667 in ......................................................................../usr/bin/clickhouse
11. Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000015c7893c in ......................................................................../usr/bin/clickhouse
12. ? @ 0x00007fde327d0609 in ?
13. ? @ 0x00007fde326f5353 in ?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ".../tests/migrations/test_runner.py", line 326, in test_reverse_all
    runner.reverse_migration(migration, force=True)
  File ".../snuba/migrations/runner.py", line 391, in reverse_migration
    self._reverse_migration_impl(migration_key)
  File ".../snuba/migrations/runner.py", line 453, in _reverse_migration_impl
    migration.backwards(context, dry_run)
  File ".../snuba/migrations/migration.py", line 193, in backwards
    op.execute()
  File ".../snuba/migrations/operations.py", line 81, in execute
    connection.execute(self.format_sql(), settings=self._settings)
  File ".../snuba/clickhouse/native.py", line 291, in execute
    raise ClickhouseError(e.message, code=e.code) from e
snuba.clickhouse.errors.ClickhouseError: DB::Exception: Could not find table: eap_trace_item_attrs_local. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c61ff37 in ......................................................................../usr/bin/clickhouse
1. DB::Exception::Exception<String&>(int, FormatStringHelperImpl<std::type_identity<String&>::type>, String&) @ 0x00000000074a968d in ......................................................................../usr/bin/clickhouse
2. DB::InterpreterAlterQuery::executeToTable(DB::ASTAlterQuery const&) @ 0x0000000011d8bba9 in ......................................................................../usr/bin/clickhouse
3. DB::InterpreterAlterQuery::execute() @ 0x0000000011d88230 in ......................................................................../usr/bin/clickhouse
4. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x00000000122bfe15 in ......................................................................../usr/bin/clickhouse
5. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x00000000122bb5b5 in ......................................................................../usr/bin/clickhouse
6. DB::TCPHandler::runImpl() @ 0x0000000013137519 in ......................................................................../usr/bin/clickhouse
7. DB::TCPHandler::run() @ 0x00000000131498f9 in ......................................................................../usr/bin/clickhouse
8. Poco::Net::TCPServerConnection::start() @ 0x0000000015b42834 in ......................................................................../usr/bin/clickhouse
9. Poco::Net::TCPServerDispatcher::run() @ 0x0000000015b43a31 in ......................................................................../usr/bin/clickhouse
10. Poco::PooledThread::run() @ 0x0000000015c7a667 in ......................................................................../usr/bin/clickhouse
11. Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000015c7893c in ......................................................................../usr/bin/clickhouse
12. ? @ 0x00007fde327d0609 in ?
13. ? @ 0x00007fde326f5353 in ?

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@volokluev volokluev merged commit 20fefa0 into master Feb 27, 2025
32 checks passed
@volokluev volokluev deleted the volo/smart_autocomplete/cleanup branch February 27, 2025 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants