quick question: I'm using the clickhouse destinati...
# replication-troubleshooting
g
quick question: I'm using the clickhouse destination to move some data and i've found airbyte is moving all data into a
public
database inside clickhouse instead of the database I indicated in the destination config page. Is this because the connector is still in alpha?
s
Hey @Gerard Clos, thanks for the question. Could you provide some more context on you configured the database you’re using for the clickhouse destination connector?
g
Aloja 👋 So I'm moving data from a postgres db to clickhouse. The schema of the tables in postgres is "public" and I think that is the reason why airbyte is importing those in a "public" database in clickhouse. I say so because when I import from another source to clickhouse (e.g google sheets connector), data is correctly imported into the warehouse I indicated in the clickhouse destination settings.
any idea why could this be happening?
nevermind, I figured it out: connection has the default option "mirror source structure" instead of "destination default" and so it was matching the sources' schema with a new database (🤷 ) in the destination
r
Hey @Gerard Clos, my name is Ryadh and I work on the integrations at ClickHouse. If you have any feedback about the ClickHouse connector, please don’t hesitate to share! we are constantly monitoring for improvements
g
Found a bug, maybe you know about it, when using incremental - append strategy the replication fails with this error.
Copy code
DB::Exception: System call renameat2() is not supported.
And I imagine it's because of this.
r
Interesting! thanks for sharing. We will investigate! Are you using ZFS as well? cc. @Geoff Genz, @Mikhail Shustov
g
I'm running clickhouse inside docker with the official image, clickhouse data mounted in a docker volume, no extra configuration. So it might be that it's using ZFS under the hood, although not sure.
👍 1
s
Thanks @Gerard Clos for digging into this and finding the solution to your problem. For future reference, where did you find the “mirror source structure” value and how were you able to change it?
g
it's one of the options of destination namespace in the connection settings
s
Thanks Gerard, hopefully this helps future users if they run into the same problem
1
b
getting the same renameat2() bug, on the clickhouse/clickhouse-server docker image on an m1 pro chip
g
If you're using the latest dbt-clickhouse version (1.3.0), it's just an information message. See my comments here: https://github.com/ClickHouse/dbt-clickhouse/issues/111
Only in version 1.1.8 is it an actual problem
(In the next patch release 1.3.1 the stack trace in the info message will be removed)
apparently the docker file system on Mac M1 doesn't support that low level operation
b
Yeah, but it effeectively makes normalization fails and makes clickhouse unusable
g
If normalization is failing it's not because of the rename table issue.
Incremental materializations are already challenging on ClickHouse because it doesn't support row based deletes or updates. The current dbt-clickhouse implementation is also not well suited for large datasets. It would be much appreciated if you could provide the details of the data you're working with and how it fails in an issue here: https://github.com/ClickHouse/dbt-clickhouse/issues it will help us improve the plugin.
b
Here's for example what we get:
Copy code
8 of 41 ERROR creating sql incremental model pipedrive.pipedrive_activities_scd ........................................ [ERROR in 31.13s]
11 of 41 ERROR creating sql incremental model pipedrive.pipedrive_deals_scd ............................................ [ERROR in 14.65s]
14 of 41 ERROR creating sql incremental model pipedrive.pipedrive_organizations_scd .................................... [ERROR in 11.73s]
16 of 41 ERROR creating sql incremental model pipedrive.pipedrive_persons_scd .......................................... [ERROR in 9.55s]
17 of 41 ERROR creating sql incremental model pipedrive.pipedrive_pipelines_scd ........................................ [ERROR in 1.76s]
18 of 41 ERROR creating sql incremental model pipedrive.pipedrive_stages_scd ........................................... [ERROR in 1.78s]
19 of 41 ERROR creating sql incremental model pipedrive.pipedrive_users_scd ............................................ [ERROR in 2.26s]
Database Error in model pipedrive_activities_scd (models/generated/airbyte_incremental/scd/pipedrive/pipedrive_activities_scd.sql)
  :HTTPDriver url <http://localhost:8123> returned response code 500)
   Code: 1. DB::Exception: System call renameat2() is not supported. (UNSUPPORTED_METHOD) (version 22.10.2.11 (official build))
  compiled Code at ../build/run/airbyte_utils/models/generated/airbyte_incremental/scd/pipedrive/pipedrive_activities_scd.sql
Database Error in model pipedrive_deals_scd (models/generated/airbyte_incremental/scd/pipedrive/pipedrive_deals_scd.sql)
  :HTTPDriver url <http://localhost:8123> returned response code 500)
   Code: 1. DB::Exception: System call renameat2() is not supported. (UNSUPPORTED_METHOD) (version 22.10.2.11 (official build))
It is the pipedrive integration
g
what is the dbt-clickhouse version?
b
Not sure what the airbyte normalizer uses
Copy code
2022-11-16 08:45:30 normalization > DBT >=1.0.0 detected; using 10K event buffer size
2022-11-16 08:45:30 INFO i.a.w.n.NormalizationAirbyteStreamFactory(filterOutAndHandleNonAirbyteMessageLines):104 - 
2022-11-16 08:45:48 normalization > Running with dbt=1.3.0
Is there any other ports except for 8123 and 9000 that should be forwarded?
g
No, those ports should be sufficient and that error wouldn't be affected anyway. I don't know anything about pipedrive but I would expect a different error if was actually using dbt-clickhouse. Let me dig into a bit.
It looks like airbyte has the bad version hard coded 😞
b
Yeah was fearing this was the case. I'll create an issue
g
did you create the issue @Berzan Yildiz? having the same problem on my end can't do incremental syncs to clickhouse
g
@Gerard Clos Are you seeing the same error? Can share version numbers and any error messages?
g
yep. Trying to replicate incrementally to a clickhouse instance within a docker container (using the official clickhouse docker image). It fails with this error:
Copy code
:HTTPDriver url <http://host.docker.internal:8123> returned response code 500)
airbyte-worker      | 2023-01-19 12:23:31 normalization >    Code: 1. DB::Exception: System call renameat2() is not supported. (UNSUPPORTED_METHOD) (version 22.10.2.11 (official build))
I can confirm the issue does not happen if you try to replicate into a clickhouse instance that is not in a docker container. So the issue is most probably because of this: https://github.com/ClickHouse/ClickHouse/issues/37583
g
The current version of airbyte should just log that error as a warning and keep working
g
nope, it fails to normalize
the tables get created but no data is inserted
replication works just to be clear, it's the normalization step that fails
g
is there anything else in the log? In particular something referencing the dbt version?
g
let me check
g
Yeah Airbyte does most things in Java, but delegates normalization to dbt
(which is Python)
g
hmm yep you were right I think there's something fishy with our config, I can see this error
it seems it does find some kind of config?
g
Yeah I have no idea what that means, but it doesn't seem ClickHouse related. Is there any other logging around the
renameat2()
error? That is expected if ClickHouse doesn't support
EXCHANGE TABLES
(trying to exchange tables is currently the only way to test), but as I said, dbt/normalization should just keep going after that.
g
no nothing more related to renameat2()
I attach the complete logs. The only error I see is:
Copy code
Internal Server Error: Could not find configuration for STANDARD_SYNC: 6f4c4ef8-22f2-4718-a99c-5ec6e2a8992e.
But maybe you see something more
cc @Andres Gutierrez
a
👋 Hi everyone, I'm also interested in this issue
I found this doc that says
Our current version of incremental is append.
We are trying
incremental + dedup
and is failing. I changed to
incremental + append
and the sync is working The question is: Do you know if we need to do something special on our Airbyte to make
incremental + dedup
SYNC work? This error in the log I think is interesting
Copy code
Completed with 1 error and 0 warnings:
normalization > Database Error in model ls_13_incremental_contacts_zoho_crm_stream_scd (models/generated/airbyte_incremental/scd/[WORKSPACE_NAME]/ls_13_incremental_contacts_zoho_crm_stream_scd.sql)
HTTPDriver for https://{CLICKHOUSE_URL} returned response code 500)
DB::Exception: ALTER UPDATE/ALTER DELETE statement with subquery may be nondeterministic, see allow_nondeterministic_mutations setting. (BAD_ARGUMENTS) (version 22.12.1.21301 (official build))
g
@Andres Gutierrez I agree that error message looks like it might be a big part of the problem. I can't tell much more without seeing what SQL airbyte is generating, but I do know that dbt-clickhouse doesn't support anything that looks like dedup.
a
Hi @Geoff Genz thanks for the reply! So you think even if we manage to configure our Clickhouse with
allow_nondeterministic_mutations
flag enable it
incremental + dedup
won't work?
g
Well I can't see what airbyte is trying to do, but if it's trying to alter a key column you will probably just get another error
👍 1
a
g
In dbt the only ALTER that dbt-clickhouse allows is in an
update_rows
function. ClickHouse doesn't allow updates of key columns.
I think we have to dig into this issue and figure out exactly how Airbyte is trying to use dbt with an 'incremental + dedup' strategy.
👏 1
a
Hi @Geoff Genz I have new insights related with
Airbyte -> Clickhouse
integration So to resume we want to do
incremental + dedup
on all streams in the source. I'm trying connecting my local Airbyte with a local Clickhouse and with a instance hosted on
Clickhouse Cloud
. In my local Clickhouse updating streams configured as
incremental + dedup
does not fail but the update takes longer that initial full scan of the source. 1. Full scan: 4m 2. Incremental Update: 7m In the case of Clickhouse CLOUD. Incremental update fails with this error:
Copy code
:HTTPDriver for <https://MY_ID_HERE>.[thing].aws.clickhouse.cloud:8443 returned response code 500
Code: 36. DB::Exception: ALTER UPDATE/ALTER DELETE statement with subquery may be nondeterministic, see allow_nondeterministic_mutations setting. (BAD_ARGUMENTS)
The weird thing is that my LOCAL clickhouse doesn't have either
allow_nondeterministic_mutations
flag enabled looking on clickhouse console
Copy code
SELECT value FROM system.settings where name='allow_nondeterministic_mutations'

SELECT value
FROM system.settings
WHERE name = 'allow_nondeterministic_mutations'

Query id: e361bd2f-a7a1-46f4-98f6-042e90e7a82a

┌─value─┐
│ 0     │
└───────┘

1 row in set. Elapsed: 0.014 sec.
Do you have any idea why 1. And incremental update takes longer that initial full scan? 2. How is possible that's working in my local clickhouse even if I don't have
allow_nondeterministic_mutations
?
g
Incremental updates using default dbt-clickhouse strategy are quite slow. The diagram here should give an idea why: https://clickhouse.com/docs/en/integrations/dbt/dbt-incremental-model#internals
As for the exception, it would be helpful to track down the actual SQL query that is raising it. I don't know if it's logged by default on an exception, but it probably should be 🙂
a
Thanks!
g
airbyte/dbt-clickhouse really shouldn't be doing alter statements . . .
a
So dbt-clickhouse should not be used for incremental + dedup updates?
Ah yes
It's weird that they do do ALTER statements
g
I wouldn't recommend the version that's embedded in Airbyte for large datasets
with light weight deletes (experimental in dbt-clickhouse 1.3.2) and the very latest ClickHouse version the performance should be better
but there's not been a lot of large scale tests with that
a
Well, my dataset is not very large. It's a zoho connector with my Sandbox zoho account which is almost empty. I have a contact xD
But is true it generates a lot of tables in clickhouse.
g
and I haven't had a chance to figure out where that ALTER is coming from. dbt has an update method that uses it but I don't know in what circumstances (and it probably shouldn't)
7 minutes implies large
(but things are slow when run through airbyte/dbt)
a
Why ALTER is bad? I would like to understand the issue
Because writing in Clickhouse is slow or because is dangerous and can lost data?
g
ClickHouse is not designed to update data. It's designed for immutable data. ALTER is an async mutation that is slow and has to be coordinated among all replicas.
a
Oh shit sounds really bad. So I think
incremental + dedup
is not a good idea for Clickhouse
Or do you think is somehow a way of configuring it to work better? I'll try tomorrow playing with
allow_nondeterministic_mutations
flag to see if perfomance improve
g
Hey @Geoff Genz quick question. We are considering moving away from clickhouse as our destination considering it's not ideal for incremental replication. What destination would you recommend in terms of airbyte support? BigQuery? I'm looking for the ones that have the most stable connectors and we know are gonna perform properly with several types of syncing strategies.
g
You're asking the wrong person 🙂. I work for ClickHouse, and I don't think you'll find a better combination of performance and cost with much else.
g
oh apologies I thought you worked for airbyte. The thing is that not supporting incremental updates is a show stopper for us. We can't afford to do full refresh syncs regularly.
g
You generally need to think about your use case and your data structures to work around certain limitations. Airbyte can make that difficult at times because the actual work is abstracted under several layers.
If you have a lot of mutable data then another database might indeed be a better choice. There's an inherent tradeoff between fast updates for individual keys and the fast aggregate/analytic powers of a "sparse index" OLAP store like ClickHouse.
👌 2