Перейти к основному содержимому
Перейти к основному содержимому

Error 49: LOGICAL_ERROR

подсказка

This error indicates an internal bug or assertion failure in ClickHouse that should not occur under normal circumstances. It represents a violation of internal invariants or unexpected conditions that point to a bug in ClickHouse itself rather than a user error.

Most common causes

  1. Internal assertion failures

    • Failed internal consistency checks
    • Invariant violations in ClickHouse code
    • Unexpected state transitions that should never happen
    • Buffer or pointer validation failures
  2. File system cache issues

    • Inconsistent cache state in S3 or remote filesystem operations
    • Buffer offset mismatches (e.g., "Expected X >= Y")
    • File segment inconsistencies
  3. Merge tree operations

    • Part management issues (e.g., "Entry actual part isn't empty yet")
    • Temporary part conflicts
    • Part state inconsistencies during merges or mutations
  4. Query optimizer or planner bugs

    • Incorrect operand types in expressions
    • Invalid query plan generation
    • Column type mismatches in internal processing
  5. Concurrency and synchronization issues

    • Race conditions in multi-threaded operations
    • Lock ordering violations
    • State corruption from concurrent access
  6. LLVM compilation errors

    • Incorrect operand types in compiled expressions
    • JIT compilation failures

What to do when you encounter this error

1. This is a bug - report it to ClickHouse

LOGICAL_ERROR always indicates a bug in ClickHouse, not a user error. The error message typically says "Report this error to https://github.com/ClickHouse/ClickHouse/issues"

2. Gather diagnostic information

Before reporting, collect:

-- Get the full error message and stack trace from logs
SELECT 
    event_time,
    query_id,
    exception,
    exception_code,
    stack_trace
FROM system.query_log
WHERE exception_code = 49
ORDER BY event_time DESC
LIMIT 10;

3. Note your ClickHouse version

SELECT version();

4. Try to create a minimal reproducible example

If possible, identify:

  • The specific query that triggers the error
  • Table schema and sample data
  • Any recent operations (merges, mutations, ALTER statements)

5. Check if the issue is already fixed

Search existing issues on GitHub Consider upgrading to a newer version if available.

Temporary workarounds

While waiting for a fix, you may try:

1. Restart the server or retry the operation

# Sometimes temporary state corruption can be cleared
sudo systemctl restart clickhouse-server

2. Optimize or rebuild affected parts

-- For specific table issues
OPTIMIZE TABLE your_table FINAL;

-- Or detach and reattach the table
DETACH TABLE your_table;
ATTACH TABLE your_table;

3. Disable experimental features

-- If using experimental features, try disabling them
SET allow_experimental_analyzer = 0;
SET compile_expressions = 0;

4. Adjust settings that may trigger the bug

-- For filesystem cache issues
SET enable_filesystem_cache = 0;

-- For query optimization issues
SET query_plan_enable_optimizations = 0;

5. Use alternative query formulation

If a specific query pattern triggers the error, try rewriting the query differently.

Common specific scenarios

Scenario 1: Buffer offset mismatch

Logical error: 'Expected 46044 >= 88088'

This typically occurs with S3 or remote filesystem cache. Try:

  • Clearing the filesystem cache
  • Disabling cache temporarily
  • Upgrading to a newer version

Scenario 2: Part management errors

Logical error: 'Entry actual part isn't empty yet'

Related to merge tree part operations. Try:

  • OPTIMIZE TABLE FINAL
  • Checking for stuck merges in system.merges
  • Checking mutations in system.mutations

Scenario 3: LLVM compilation errors

Logical error: Incorrect operand type

Related to expression compilation. Try:

SET compile_expressions = 0;
SET compile_aggregate_expressions = 0;