Use Snapshot isolation mode for SQL Server, if not read_committed is also a good option

Description

The repeatable_read isolation mode which is the default, keeps shared lock on the rows read till the initial snapshot completes. If the initial snapshot takes long, this can block other queries. Discussed the same with the Debezium team . Recommendations are

 

  1. Use snapshot isolation mode if possible. Full consistency is guaranteed and no locks are taken during initial snapshot

  2. Use read_committed if schema modification will not happen during initial snapshot. This does not prevent concurrent updates to the table. This should be a reasonable option for most customers.

  3. Use repeatable_read. Shared locks prevent concurrent updates while the initial snapshot is taken.

The above will be doc changes. In addition, we can look at checking if snapshot isolation is set on the SQL Server. If it is automatically select snapshot isolation which is the most ideal option. Enabling snapshot isolation on the SQL Server has overhead. But since the customer has already chosen it, best option is to use it for the initial snapshot of the table as well.

Here is the discussion with Debezium team https://debezium.zulipchat.com/#narrow/stream/302529-users/topic/Snapshot.20isolation.20mode.20for.20SQL.20Server/near/285385769

Snippets

  • the snapshot isolation mode is not the default one because it needs to be explicitly enabled on SQL Server. That was the only reason.

  • using repeatable_read be default prevents concurrent schema modification which read_committed does not, so it is a safer option

Other context

Query to determine if Snapshot isolation is enabled

Release Notes

None

Activity

Show:

Avinash AcharSeptember 12, 2022 at 10:47 AM

Not enough bandwidth to tackle in 6.8. Prioritising other replication issues.

Robin RielleyJuly 20, 2022 at 9:27 PM

KI was posted:

Robin RielleyJune 22, 2022 at 3:10 PM
Edited

We just need to write a known issue and Olivia can post for CDF and I can post for CDAP (I’ll list it with the 6.6.0/6.7.0 release notes.).

Question:

Is this for SQL Server Batch Source or the SQL Server replication source?

Sanket SahuJune 22, 2022 at 1:28 PM

,
Moving it to 6.8.0 but need to document it as known issue. How do we do it?

Sanket SahuJune 16, 2022 at 6:14 PM

The main tasks :
* Find a way to check if we can SQL server’s snapshot mode is enabled.
* If snapshot mode not possible , then should we go with read_committed or fall back to default repeatable_read , we need to decide on it

Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Affects versions

Triaged

No

Size

M

Original estimate

Time tracking

No time logged1w remaining

Components

Fix versions

Priority

Created June 14, 2022 at 2:37 AM
Updated April 21, 2023 at 10:56 AM