Skip to content

[BUG] ClickHouse Error 62 during DELETE replication - unquoted DateTime values #257

@VladimirDVV

Description

@VladimirDVV

Bug Description

ClickHouse Error Code 62 (SYNTAX_ERROR) occurs during DELETE/ERASE operations when replicating from MySQL to ClickHouse. The error happens because DateTime64 values are not properly quoted in the generated SQL query. The replicator crashes in a loop when processing erase events.

Steps to Reproduce

Set up mysql_ch_replicator v0.1.15 with MySQL and ClickHouse (25.8.18.1-yc.1 on Yandex Cloud)
Configure realtime replication with tables containing TIMESTAMP/DATETIME columns
Perform DELETE operations on MySQL tables that have DateTime64 fields in ClickHouse
Observe the replicator crash when processing erase events

Expected Behavior

DELETE operations from MySQL should be properly replicated to ClickHouse using the erase() method with correctly formatted SQL queries (DateTime values should be wrapped in single quotes).

Actual Behavior

The replicator crashes with ClickHouse Error Code 62:

clickhouse_connect.driver.exceptions.DatabaseError: HTTPDriver for url received ClickHouse error code 62
Code: 62. DB::Exception: Syntax error: failed at position 76 (04): 04:15:01,246604370), (1225,2026-04-01 04:15:01,246604337), (1225,2026-04-01 04:15:01,246604365)...
Expected one of: token, DoubleColon, Comma, ClosingRoundBracket, OR, AND, IS NOT DISTINCT FROM, IS NULL, IS NOT NULL, BETWEEN, NOT BETWEEN, LIKE, ILIKE, NOT LIKE, NOT ILIKE, REGEXP, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, MOD, DIV, alias, AS. (SYNTAX_ERROR) (version 25.8.18.1-yc.1)

Stack trace location:
File: /app/mysql_ch_replicator/clickhouse_api.py, line 391, in erase()
File: /app/mysql_ch_replicator/clickhouse_api.py, line 190, in execute_command()
Problem: DateTime values appear without quotes: 2026-04-01 04:15:01.246604370 instead of '2026-04-01 04:15:01.246604370'

Environment

  • mysql_ch_replicator version: v0.1.15 (latest)
  • Operating System: Linux (Docker container)
  • Python version: 3.12
  • ClickHouse version: 25.8.18.1-yc.1 (Yandex Cloud Managed ClickHouse)
  • MySQL version: MySQL 8.0 (Yandex Cloud Managed MySQL)

MySQL Configuration

# Yandex Cloud Managed MySQL (default settings)
[mysqld]
binlog_format=ROW
binlog_row_image=FULL
log_bin=mysql-bin
server_id=1

Replicator Configuration

mysql:
      host: host
      port: port
      user: user
      password: password
      charset: "utf8mb4"

clickhouse:
      host: host
      port: port
      user: user
      password: password

binlog_replicator:
      data_dir: "/app/data/"
      records_per_file: 100000
initial_replication_threads: 2
enable_optimize_final: False
ignore_deletes: false
optimize_interval: 86400

skip_initial_replication : True

databases: "database"  
tables: ['table1', 'table2']     

target_databases:
       database: database
log_level: "info"
mysql_timezone: 'UTC'
version_initial_value: 17008437

Additional Information

Error occurs specifically in the erase() method when processing DELETE events
Stats show: erase_events_count: 2, erase_records_count: 2 before crash
The replicator enters a crash loop - restarts and fails again immediately

mysql_ch_replicator_log.txt

schemes.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions