Why in a CDC connection when a record is deleted t...
# replication-ask-ai
á
Why in a CDC connection when a record is deleted the deletion is not propagated into the destination? We can still see in the destination records that have been deleted in source
k
In a standard incremental replication, the system periodically executes queries on a source system for new or updated records, and then transmits the results of these queries to the destination. However, because a query cannot return deleted records, standard incremental replication does not correctly transmit deletions from the source to the destination. This is because the records that are replicated to the destination are selected by a query on the source system for records that have been inserted or modified since the last synchronization. Any records that have been deleted are not returned by such a query, and therefore deleted records are not propagated to the destination [source](https://airbyte.com/tutorials/incremental-data-synchronization). On the other hand, Change Data Capture (CDC) incremental replication reads a log of the changes that have been made to the source database and transmits these changes to the destination. Because changes are read from a transaction log when using CDC, it is not necessary for the source data to have a suitable cursor field. Additionally, intermediate changes and deletions on the source are correctly transmitted to the destination because they are logged just like any other modification to the source data [source](https://airbyte.com/tutorials/incremental-change-data-capture-cdc-replication). So, if you are using CDC replication and deletions are not being propagated to the destination, it might be due to some misconfiguration or issue with the CDC setup. You should check your CDC settings and ensure that your source database is correctly configured for CDC. For example, in MySQL, you must enable binary logging for MySQL replication [source](https://docs.airbyte.com/integrations/sources/mysql).
á
@kapa.ai which would be the correct config in airbyte?
k
The correct configuration in Airbyte depends on the specific source and destination you are working with. However, here are some general steps you can follow: 1. Create a Connection: After creating a connection, you can modify how your data syncs to the destination by changing the configuration settings and the stream settings. You can do this from the Airbyte Cloud dashboard by clicking on Connections and then the connection you want to change ([source](https://docs.airbyte.com/cloud/managing-airbyte-cloud/configuring-connections)). 2. Configure Connection Settings: You can manage various aspects of the sync, such as how often data syncs and where data is written. These settings apply to all streams in the connection. Some of the settings you can configure include Replication frequency, Destination namespace, Destination stream prefix, and how Airbyte handles syncs when it detects schema changes in the source ([source](https://docs.airbyte.com/cloud/managing-airbyte-cloud/configuring-connections)). 3. Configure the Airbyte MongoDB Source: If you are using MongoDB as a source, you can configure it using the database credentials and connection string ([source](https://docs.airbyte.com/integrations/sources/mongodb-v2)). 4. Set up a Connection: After deploying Airbyte locally and setting up your first source and destination, you can create your first connection. You can configure the connection, set the Replication frequency, and choose which streams you want to replicate ([source](https://docs.airbyte.com/quickstart/set-up-a-connection)). 5. Add a Source: You can set up a new source in Airbyte by clicking the Sources tab in the Airbyte UI. Each connector in Airbyte will have its own set of authentication methods and configurable parameters ([source](https://docs.airbyte.com/quickstart/add-a-source)). Remember, the specific configuration settings will depend on the source and destination you are using. Always refer to the specific documentation for your source and destination for the most accurate information.
á
@kapa.ai I'm using MySQL to BigQuery and I need to know the specific settings in airbyte sync so that the CDC ingestion deletes records when they are deleted in the source
k
A message from kapa.ai
To set up Change Data Capture (CDC) from MySQL to BigQuery using Airbyte, you need to follow these steps: 1. Set up MySQL Source: First, you need to set up MySQL as a source in Airbyte. You need to provide the necessary credentials and enable CDC. For CDC, you need to grant additional permissions to the Airbyte user like
SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT
([source](https://docs.airbyte.com/integrations/sources/mysql)). 2. Set up BigQuery Destination: Next, set up BigQuery as the destination. Provide the necessary credentials and details for your BigQuery instance. 3. Create a Connection: Now, go to connections and create a new connection. Select the MySQL source and BigQuery destination you just created. 4. Configure the Connection: In the connection settings, set the replication frequency as per your needs. You can set it to manual for triggering synchronization on demand or set it to sync as frequently as every 5 minutes ([source](https://airbyte.com/tutorials/mysql-change-data-capture-cdc)). 5. Select Sync Mode: For taking full advantage of CDC, select the
Incremental | Append
sync mode. This mode only looks at the rows that have changed in the source and syncs them to the destination. This way, when a record is deleted in the source, it will also be deleted in the destination ([source](https://airbyte.com/tutorials/mysql-change-data-capture-cdc)). 6. Run the Sync: Save the changes and run your first sync by clicking on
Sync now
. You can check your run logs to verify everything is going well. Remember, CDC with Airbyte allows you to replicate deletes from the source to the destination, which is what you want in your case ([source](https://airbyte.com/tutorials/mysql-change-data-capture-cdc)).
á
Isn't it incremental append + deduped? @kapa.ai
k
A message from kapa.ai
Yes, you're correct. If you want to handle deletions from the source in your destination, you should use the
Incremental - Append Deduped
sync mode in Airbyte. This mode is designed to handle updates and deletions from the source. In this mode, Airbyte creates an intermediate table in which it loads the latest data. It then compares this data to the data already in the destination table and updates the destination table to match the latest data. This includes deleting any records in the destination that were deleted in the source. Here's how you can set it up: 1. Create a Connection: Go to connections and create a new connection. Select the MySQL source and BigQuery destination you just created. 2. Select Sync Mode: In the connection settings, select the
Incremental - Append Deduped
sync mode for the tables you want to sync. This mode will handle updates and deletions in the source. 3. Run the Sync: Save the changes and run your first sync by clicking on
Sync now
. You can check your run logs to verify everything is going well. Remember, when using CDC, you don't need to provide a cursor field, as changes in the source are detected via the Debezium connector stream ([source](https://airbyte.com/tutorials/incremental-change-data-capture-cdc-replication)).