Fivetran ClickHouse Destination - Troubleshooting & Best Practices
Configuring batch sizes
Many of the errors below can be mitigated by tuning batch sizes via a JSON configuration file. See the Advanced configuration section of the setup guide for full details.
Quick reference:
| Setting | Default | Min | Max |
|---|---|---|---|
write_batch_size | 100,000 | 5,000 | 100,000 |
select_batch_size | 1,500 | 200 | 1,500 |
mutation_batch_size | 1,500 | 200 | 1,500 |
hard_delete_batch_size | 1,500 | 200 | 1,500 |
Common errors
AST is too big (code 168)
Error message:
Cause: Large UPDATE or DELETE batches generate SQL statements with very complex abstract syntax trees. Common with wide tables or history mode enabled.
Solutions:
- Reduce batch sizes (recommended): Lower
mutation_batch_sizeandhard_delete_batch_sizein the configuration file. - Increase ClickHouse limits (workaround):
Note
Increasing these values raises safety limits for query parsing. Monitor CPU and memory usage after making this change.
Max query size exceeded (code 62)
Error message:
Cause: The generated SQL exceeds the max_query_size limit (default: 262,144 bytes). Common with history mode or wide tables.
Solutions:
- Reduce batch sizes: Lower
mutation_batch_sizeandhard_delete_batch_size. - Increase
max_query_size:
Memory limit exceeded / OOM (code 241)
Error message:
Cause: The INSERT operation requires more memory than available. Happens during large initial syncs, with wide tables, or concurrent batch operations.
Solutions:
- Reduce
write_batch_size: Lower to 50,000 or even 5,000 for very large tables. - Scale up the ClickHouse Cloud service to provide more memory.
- Reduce concurrent load: If the source produces very wide CSV files (200+ columns), the connector may need more memory.
If the connector pod itself is killed by OOM (no error in ClickHouse logs), the issue is on the Fivetran side. Reducing write_batch_size to 5,000 may help. Improvements to stream CSV data in batches are in development.
Inactive replicas during ALTER/DELETE (code 341)
Error message:
Cause: A DDL or lightweight DELETE was executed, but one or more replicas are inactive. This can happen when ClickHouse Cloud has a stopped or idling child service (compute-compute separation). The connector checks system.replicas and finds inactive entries from the idle service.
Solutions:
- Start or remove the idle child service. Once all child services are running or removed, the connector finds all replicas active.
- Set
lightweight_deletes_syncto 3 for the Fivetran user:NoteRecent versions of the connector apply this setting by default and exclude idle instances from DDL wait logic.
- Verify replica status:
Replica not available / Failed after 600 attempts
Error message:
Cause: The connector waits up to 600 seconds for all replicas to become available. This fails when:
- Nodes are offline or unhealthy.
- Orphaned replica entries remain after a service migration or resize.
Solutions:
- Ensure all nodes are running: All replicas must be online during Fivetran syncs.
- Check for orphaned replicas: After a service migration, old replica names may remain in
system.replicas. Remove them: - Check the ClickHouse Cloud console for scaling events or maintenance windows.
Database name occupied by another replica (code 341)
Error message:
Cause: A race condition during CREATE DATABASE IF NOT EXISTS when multiple replicas are active, typically during the first historical sync with multiple tables being created concurrently.
Solutions:
- Retry the sync: This is usually transient during initial setup.
- Check replica status in the ClickHouse Cloud console.
- Open a support ticket if the error persists across multiple retries.
Unexpected EOF / Connection error
Error message:
Or FAILURE_WITH_TASK with no stack trace in Fivetran logs.
Cause:
- IP access list not configured to allow Fivetran traffic.
- Transient network issues between Fivetran and ClickHouse Cloud.
- Corrupted or invalid source data causing the destination connector to crash.
Solutions:
- Check IP access list: In ClickHouse Cloud, go to Settings > Security and add the Fivetran IP addresses or allow access from anywhere.
- Retry: Recent connector versions automatically retry EOF errors. Sporadic errors (1–2 per day) are likely transient.
- If the issue persists: Open a support ticket with ClickHouse providing the error time window. Also ask Fivetran support to investigate source data quality.
Truncate before time is zero
Error message:
Cause: A bug in the connector where timestamps with exactly 0 seconds and 0 nanoseconds (e.g., 10:00:00) were incorrectly treated as invalid. Fixed in connector PR #49 (December 2025).
Solutions:
- Ensure you are running the latest version of the ClickHouse Fivetran destination.
- If the error persists: The issue may be caused by corrupted source data. Contact Fivetran support.
Can't map type UInt64
Error message:
Cause: The connector maps LONG to Int64, never UInt64. This error occurs when a user manually altered a column type in a Fivetran-managed table.
Solutions:
- Do not manually modify column types in Fivetran-managed tables.
- To recover: Alter the column back to the expected type (e.g.,
Int64) or delete and re-sync the table. - For custom types: Create a materialized view on top of the Fivetran-managed table.
No primary keys for table
Error message:
Cause: Every ClickHouse table requires an ORDER BY. When the source has no primary key, Fivetran adds _fivetran_id automatically. This error occurs in edge cases where the source defines a PK but the data does not contain it.
Solutions:
- Contact Fivetran support to investigate the source pipeline.
- Check the source schema: Ensure primary key columns are present in the data.
Role-based grants failing
Error message:
Cause: The connector checks grants with:
This only returns direct grants. Privileges assigned via a ClickHouse role have user_name = NULL and role_name = 'my_role', so they are invisible to this check.
Solutions:
- Grant privileges directly to the Fivetran user:
- A fix for the connector to also check
system.role_grantsis tracked.
Network closed / Sync rescheduled
Error message:
Syncs fail with "Network closed for unknown reason" and are rescheduled.
Cause:
- Connector pod OOM killed (process terminates with no error logged).
- Long-running query exceeds ClickHouse socket timeout (default: 300 seconds).
- Transient network issues.
Solutions:
- Check for OOM: If the connector disappears without errors, see Memory limit exceeded.
- Reduce batch sizes: See batch size configuration.
- If timeout-related (
SOCKET_TIMEOUTin ClickHouse logs): Contact ClickHouse support.
Best practices
Dedicated ClickHouse service for Fivetran
Use ClickHouse Cloud's compute-compute separation to create a dedicated service for Fivetran write workloads. This isolates ingestion from analytical queries and prevents resource contention.
Recommended architecture:
- Service A (writer): Fivetran destination + other ingestion tools (ClickPipes, Kafka connectors)
- Service B (reader): BI tools, dashboards, ad-hoc queries
Duplicate records with ReplacingMergeTree
ClickHouse uses ReplacingMergeTree for Fivetran destination tables. Duplicate rows with the same primary key are normal — deduplication happens asynchronously during background merges.
Always use the FINAL modifier to get deduplicated results:
See the data deduplication reference for more details.
Primary key and ORDER BY optimization
Fivetran replicates the source table's primary key as the ClickHouse ORDER BY clause. When the source has no PK, _fivetran_id (a UUID) becomes the sorting key, which leads to poor query performance because ClickHouse builds its sparse primary index from the ORDER BY columns.
Recommendations:
- Treat Fivetran tables as raw staging tables. Do not query them directly for analytics.
- Create materialized views with an
ORDER BYoptimized for your query patterns:
Don't manually modify Fivetran-managed tables
Avoid manual DDL changes (e.g., ALTER TABLE ... MODIFY COLUMN) to tables managed by Fivetran. The connector expects the schema it created. Manual changes can cause type mapping errors and schema mismatch failures.
Use materialized views for custom transformations.
Ensure cluster health during syncs
The Fivetran destination checks that all replicas are active before performing operations. If any replica is offline, operations fail after retrying for up to 600 seconds.
- Keep all replicas running during sync windows.
- Schedule syncs when all nodes are available if you scale down during off-hours.
- Monitor the ClickHouse Cloud console for service issues.
Tuning for large initial syncs
For large datasets (hundreds of millions of rows or multi-TB):
- Start with lower batch sizes: Set
write_batch_sizeto 50,000 or lower. - Scale up the ClickHouse Cloud service before the initial sync.
- Monitor memory usage on both ClickHouse and Fivetran sides.
- Be patient: Large syncs (10+ TB) can take days to weeks depending on data complexity, batch sizes, and source extraction speed.
BYOC compatibility
The Fivetran destination works with ClickHouse Cloud BYOC (Bring Your Own Cloud) deployments. The connector uses SharedMergeTree, which is the engine in all ClickHouse Cloud services including BYOC. There is no difference in configuration or behavior.