Skip to content

Bug: Fresh installation fails with ClickHouse UNKNOWN_IDENTIFIER errors and broken sessions functionality #1024

Description

@DamirLut

Describe the bug
Fresh install initializes ClickHouse successfully, but events table schema is incomplete.

Backend queries expect at least:

  • identified_user_id
  • ip
  • tag

But fresh ClickHouse schema does not contain them, causing sessions/users pages to fail with UNKNOWN_IDENTIFIER.

Workaround:

docker exec -it clickhouse clickhouse-client --database analytics

ALTER TABLE events
ADD COLUMN IF NOT EXISTS identified_user_id String DEFAULT '',
ADD COLUMN IF NOT EXISTS ip String DEFAULT '',
ADD COLUMN IF NOT EXISTS tag String DEFAULT '';

To Reproduce
Steps to reproduce the behavior:

  1. Pull the latest version from the repository.
  2. Perform a clean installation following the official setup instructions.
  3. Start all services.
  4. Open the dashboard.
  5. Navigate to pages that display session-related analytics.
  6. Observe backend logs.

Expected behavior
A fresh installation should work without any manual database modifications or migrations.

Session analytics pages should load successfully and backend logs should not contain ClickHouse schema errors.

Additional context

backend | [09:16:06] INFO: Database initialization complete {"service":"cluster"}
Error fetching sessions: ClickHouseError: Unknown expression or function identifier `identified_user_id` in scope AggregatedSessions AS (SELECT session_id, argMax(user_id, timestamp) AS user_id, argMax(identified_user_id, timestamp) AS identified_user_id, argMax(country, timestamp) AS country, argMax(region, timestamp) AS region, argMax(city, timestamp) AS city, argMax(language, timestamp) AS language, argMax(device_type, timestamp) AS device_type, argMax(browser, timestamp) AS browser, argMax(browser_version, timestamp) AS browser_version, argMax(operating_system, timestamp) AS operating_system, argMax(operating_system_version, timestamp) AS operating_system_version, argMax(screen_width, timestamp) AS screen_width, argMax(screen_height, timestamp) AS screen_height, argMin(referrer, timestamp) AS referrer, argMin(channel, timestamp) AS channel, argMin(hostname, timestamp) AS hostname, argMin(url_parameters, timestamp)['utm_source'] AS utm_source, argMin(url_parameters, timestamp)['utm_medium'] AS utm_medium, argMin(url_parameters, timestamp)['utm_campaign'] AS utm_campaign, argMin(url_parameters, timestamp)['utm_term'] AS utm_term, argMin(url_parameters, timestamp)['utm_content'] AS utm_content, MAX(timestamp) AS session_end, MIN(timestamp) AS session_start, dateDiff('second', MIN(timestamp), MAX(timestamp)) AS session_duration, argMinIf(pathname, timestamp, type = 'pageview') AS entry_page, argMaxIf(pathname, timestamp, type = 'pageview') AS exit_page, countIf(type = 'pageview') AS pageviews, countIf(type = 'custom_event') AS events, countIf(type = 'error') AS errors, countIf(type = 'outbound') AS outbound, countIf(type = 'button_click') AS button_clicks, countIf(type = 'copy') AS copies, countIf(type = 'form_submit') AS form_submits, countIf(type = 'input_change') AS input_changes, argMax(ip, timestamp) AS ip, argMax(lat, timestamp) AS lat, argMax(lon, timestamp) AS lon, argMax(tag, timestamp) AS tag FROM events WHERE (site_id = _CAST(1, 'Int32')) AND (timestamp > toDateTime('2026-06-15 09:26:14')) AND (timestamp <= toDateTime('2026-06-15 09:31:14')) GROUP BY session_id ORDER BY session_end DESC). Maybe you meant: ['identified_user_id']. 
backend  |     at parseError (/app/node_modules/@clickhouse/client-common/dist/error/parse_error.js:35:16)
backend  |     at ClientRequest.onResponse (/app/node_modules/@clickhouse/client/dist/connection/node_base_connection.js:409:63)
backend  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
backend  |   code: '47',
backend  |   type: 'UNKNOWN_IDENTIFIER'
backend  | }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions