Stay organized with collections
Save and categorize content based on your preferences.
This page describes how to enable transaction isolation in Microsoft SQL
Server and MySQL database snapshots in Cloud Data Fusion
replication jobs.
When you set up a replication job for a database, the job takes an
initial snapshot of the source tables. To ensure data consistency, place
locks on those tables.
After the initial snapshot, incremental changes at the source are captured and
applied to the BigQuery target as part of the ongoing replication
process.
SQL Server
To capture changes in the source tables in a SQL Server database, the
replication job uses a Debezium connector. During the
snapshotting phase,
Debezium acquires locks according to the configured
snapshot.isolation.mode.
The following table compares the supported isolation modes for
replication jobs.
Isolation mode
Acquired locks
Data consistency
read_uncommitted
None
No.
read_committed
Shared locks on a batch of rows at a time
Partial. An added record can appear twice: once in the initial
snapshot and once in the streaming phase.
repeatable_read (default)
Shared locks on all rows
Partial. An added record can appear twice: once in the initial
snapshot and once in the streaming phase.
By default, the snapshot isolation mode is repeatable_read. This mode takes
shared locks on all data that's read during the snapshotting phase. It
prevents other transactions from modifying the existing rows, and can
potentially allow insertion of new records (see
lock escalation).
Replication with snapshot isolation is recommended if it's already enabled on
the source database because it provides full data consistency without locking
the tables. If it's not enabled, learn more about the impact of
row versioning-based isolation levels in the SQL Server Database Engine
before you enable it.
As an alternative, use the read_committed isolation mode, which
doesn't lock the tables during the snapshotting phase.
Enable snapshot isolation in a replication job
Enable snapshot isolation in the SQL Server database:
ALTER DATABASE DATABASE_NAME
SET ALLOW_SNAPSHOT_ISOLATION ON
Replace DATABASE_NAME with the name of the SQL Server
database.
To capture changes in the source tables in a MySQL database, the
replication job uses a Debezium connector. During the
snapshotting phase,
Debezium acquires locks according to the configured
snapshot.locking.mode.
By default, the snapshot locking mode is minimal. In this mode, the
connector holds the global read lock for the initial portion of the snapshot
as it reads the database schemas and other metadata. Then the connector
fetches all rows through a consistent read, using the REPEATABLE READ
transaction, which doesn't lock the tables.
To prevent any locks, set the mode to none.
As an alternative, to prevent locks on MySQL databases running on
Cloud SQL, replicate from the
Replica
instead of the transactional database.
Change the locking behavior during the snapshot for MySQL
To change snapshot locking behavior in the MySQL database, set the runtime
argument, snapshot.locking.mode property, to an appropriate
locking mode value.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis document details how to manage transaction isolation and locking during the snapshotting phase of replication jobs in Microsoft SQL Server and MySQL databases within Cloud Data Fusion.\u003c/p\u003e\n"],["\u003cp\u003eFor SQL Server, setting the \u003ccode\u003esnapshot.isolation.mode\u003c/code\u003e to \u003ccode\u003esnapshot\u003c/code\u003e provides full data consistency without locking tables, though it requires enabling snapshot isolation in the SQL Server database.\u003c/p\u003e\n"],["\u003cp\u003eSQL Server's default isolation mode \u003ccode\u003erepeatable_read\u003c/code\u003e uses shared locks, potentially allowing duplicate records; alternatively \u003ccode\u003eread_committed\u003c/code\u003e can be used but requires caution against schema changes.\u003c/p\u003e\n"],["\u003cp\u003eIn MySQL, the \u003ccode\u003esnapshot.locking.mode\u003c/code\u003e can be set to \u003ccode\u003enone\u003c/code\u003e to prevent locks, but schema changes during snapshotting should be avoided to ensure consistency, alternatively, you can replicate from the replica instead of the transactional database.\u003c/p\u003e\n"],["\u003cp\u003eOracle source replication via Datastream does not lock tables, ensuring minimal disruption.\u003c/p\u003e\n"]]],[],null,["# Isolation levels in replication\n\nThis page describes how to enable *transaction isolation* in Microsoft SQL\nServer and MySQL database snapshots in Cloud Data Fusion\nreplication jobs.\n\nWhen you set up a replication job for a database, the job takes an\ninitial snapshot of the source tables. To ensure data consistency, place\nlocks on those tables.\n\nAfter the initial snapshot, incremental changes at the source are captured and\napplied to the BigQuery target as part of the ongoing replication\nprocess. \n\n### SQL Server\n\nTo capture changes in the source tables in a SQL Server database, the\nreplication job uses a Debezium connector. During the\n[`snapshotting`](/data-fusion/docs/concepts/replication#table_states) phase,\nDebezium acquires locks according to the configured\n[`snapshot.isolation.mode`](https://debezium.io/documentation/reference/1.3/connectors/sqlserver.html#sqlserver-property-snapshot-isolation-mode).\n\nThe following table compares the supported isolation modes for\nreplication jobs.\n\nFor more information about isolation modes, see\n[Set transaction isolation level](https://learn.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level-transact-sql).\n\nBy default, the snapshot isolation mode is `repeatable_read`. This mode takes\nshared locks on all data that's read during the snapshotting phase. It\nprevents other transactions from modifying the existing rows, and can\npotentially allow insertion of new records (see\n[lock escalation](https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-transaction-locking-and-row-versioning-guide?view=sql-server-ver16#lock-escalation)).\n\nReplication with snapshot isolation is recommended if it's already enabled on\nthe source database because it provides full data consistency without locking\nthe tables. If it's not enabled, learn more about the impact of\n[row versioning-based isolation levels in the SQL Server Database Engine](https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-transaction-locking-and-row-versioning-guide?#Row_versioning)\nbefore you enable it.\n\nAs an alternative, use the `read_committed` isolation mode, which\ndoesn't lock the tables during the snapshotting phase.\n| **Warning:** If you use `read_committed` mode, ensure that no schema changes are applied on the database during the snapshotting phase, as it may cause data inconsistency in replication.\n\nEnable snapshot isolation in a replication job\n----------------------------------------------\n\n1. Enable snapshot isolation in the SQL Server database:\n\n ```\n ALTER DATABASE DATABASE_NAME\n SET ALLOW_SNAPSHOT_ISOLATION ON\n ```\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e with the name of the SQL Server\n database.\n2. Set the runtime argument `snapshot.isolation.mode` to `snapshot`. For more\n information, see\n [Pass a runtime argument to a replication job](/data-fusion/docs/how-to/pass-runtime-args-in-replication).\n\n### MySQL\n\nTo capture changes in the source tables in a MySQL database, the\nreplication job uses a Debezium connector. During the\n[`snapshotting`](/data-fusion/docs/concepts/replication#table_states) phase,\nDebezium acquires locks according to the configured\n[`snapshot.locking.mode`](https://debezium.io/documentation/reference/1.3/connectors/mysql.html#mysql-property-snapshot-locking-mode).\n\nBy default, the snapshot locking mode is `minimal`. In this mode, the\nconnector holds the global read lock for the initial portion of the snapshot\nas it reads the database schemas and other metadata. Then the connector\nfetches all rows through a consistent read, using the `REPEATABLE READ`\ntransaction, which doesn't lock the tables.\n\nTo prevent any locks, set the mode to `none`.\n| **Warning:** If you use `none`, ensure that no schema changes are applied on the database during the snapshotting phase, as it may cause data inconsistency in replication.\n\nAs an alternative, to prevent locks on MySQL databases running on\nCloud SQL, replicate from the\n[Replica](https://debezium.io/documentation/reference/1.3/connectors/mysql.html#mysql-supported-topologies_debezium)\ninstead of the transactional database.\n\nChange the locking behavior during the snapshot for MySQL\n---------------------------------------------------------\n\n- To change snapshot locking behavior in the MySQL database, set the runtime argument, `snapshot.locking.mode` property, to an appropriate [locking mode](https://debezium.io/documentation/reference/1.3/connectors/mysql.html#mysql-property-snapshot-locking-mode) value.\n\n| **Note:** Tables defined with the MyISAM engine continue to be locked despite the property being set to `none`.\n\nFor more information, see [Pass a Debezium argument to a replication job](/data-fusion/docs/how-to/pass-runtime-args-in-replication#debezium-arguments).\n\nLimitations\n-----------\n\n- Replication in Cloud Data Fusion supports Debezium Connector version 1.3.\n\nOracle sources in Cloud Data Fusion\n-----------------------------------\n\nReplication from Oracle sources in Cloud Data Fusion is powered by\nDatastream. Datastream [doesn't lock tables](/datastream/docs/faq#general-source).\n\nWhat's next\n-----------\n\n- Learn more about [Replication](/data-fusion/docs/concepts/replication)."]]