Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Mar 22, 2021 11:41:59 AM
Mar 22, 2021 11:41:59 AM
Batch Apply is the default setting because it is much faster than Transactional Apply.
Transactional Apply mode is generally slower than Batch apply mode because the task will replay the source TLog transactions exactly as they are ordered in the source TLog. Each update to a record will be applied to the target one statement at a time.
Batch Apply mode will do many optimizations to the transactions that it reads from the source Tlog. A couple of examples would be the combining of several statements on one table into a single statement. Like the Insert followed by a couple of update statements would be combined into a single Insert Statement, or several Update statements that would be combined. The most import thing that batch will do is apply all the records in the bac=tch as a single command to the target instead of hundreds, if not thousands of individual statements.
There is very little impact on performance and task log file size to have the following two components always set to trace level logging.
PERFORMANCE and TARGET_APPLY
With these preset to trace you will have information in the log that could help with troubleshooting latency.
Reindex of a SQL server source presents some issue for replicate tasks that need to be considered when planning the SQL server maintenance window.
The most important impact on a replicate task to realize about an index reorg or rebuild maintenance window is that the task will not be able to be restarted with a timestamp value that goes back to before the reindex job started. The original partition ids will be lost by the task and this will require a full load of any tables that were involved in the re-index.
The next thing to be aware of is that when a source database does a re-index maintenance window that replicate task will build up latency during the reindex job. This latency results from either of the two strategies (1. Stop and Resume task - 2. Keep task running) for handling re-index by a task.
This is all about the index reorgs and how reading backup TLogs is slow
Possible mitigating steps:
Additional information contributing to the slowdown:
Replicate uses SQLite syntax in the transformation and filter sections of the task table transformations section. We do not maintain documentation on this so if you want to read about a particular supported function or operation please refer to SQLite syntax on-line.
There are two options to choose from when setting up the MS SQL server source endpoint.
Option 1: Start transactions in the database
Note: This option must be used if there are more than one task using the same source database.
The safeguard mechanism opens 2 transactions in the source database to prevent Active Log from truncating changes that we didn't read yet. The reason for that, is that if the Active log will truncate changes while we are reading from a proximate location in the TLog, we might lose those events.
So, the safeguard will open those transactions to prevent truncation.
It opens both a "rear latch" transaction which marks the oldest record that we didn't read, and a "front latch" transaction, that is created in "now" time every time we move the safeguard.
So when we move the safeguard, we commit the rear latch transaction, open a new transaction "now" which will be the new front latch, and the old front latch will become the new rear front latch.
Replicate will move the safeguard if and only if:
The parameter of 5 minutes of safeguard, tells Replicate how often to check if we can move the safeguard.
It doesn't mean that the safeguard will move every 5 minutes, as Replicate may check and see that it didn't read yet past the rear latch, so it cannot move the safeguard.
So, you can see that with the safeguard option, you can potentiality have the long-running transactions on the database, and active log can get large and even fill out.
This is actually normal behavior, as these transactions are left open to ensure the transaction log is not truncated before all changes are read from the source.
Option 2: Exclusively use sp_repldone within a single task
For this option the task hands off the whole 'Safeguard" process to SQL server LogReader agent job.
One big issue with this issue is that when the task is stopped the LogReader will not free up the TLog for truncation. So if a task is down for a couple of days the source TLog will get very large in size.