cdr check replicateset
The cdr check replicateset command compares the data on replication servers to create a report listing data inconsistencies. Optionally you can use the command to repair the inconsistent data within a replicate.
Syntax
Element | Purpose | Restrictions | Syntax |
---|---|---|---|
checksum_function | Name of the checksum function to use during consistency checking. | The function must be installed and registered on all replication servers. | Long Identifiers |
data_server | Name of the database server to use as the reference copy of the data. | Must be the name of an existing database server group in SQLHOSTS. | Long Identifiers |
number_processes | The number of parallel processes to use for the command. | The maximum number of processes Enterprise Replication can use is equal to the number of replicates in the replicate set. | |
recheck_time | The number of seconds to spend rechecking transactions that might be listed as inconsistent because they are not yet applied on the target server. | Must be a positive integer. | |
repl_set | Name of the replicate set. Can be the name of a derived replicate set. | Long Identifiers | |
seconds | The number of seconds to wait for a disabled replication server to be recognized as active by other replication servers in the domain and how long to wait for control messages queued at peer servers to be applied at newly-enabled server. | Must be an integer value from 0 to 60. | |
start_time | The time from which to check updated rows. | Can have one the following formats:
|
The time stamp format follows the convention of the DBTIME environment variable. |
target_server | Name of a database server group to check. | Must be the name of an existing database server group in SQLHOSTS. | Long Identifiers |
task_name | The name of the progress report task. | If you use an existing task name, the information
for that task is overwritten. Maximum name length is 127 bytes. |
Long Identifiers |
The following table describes the cdr check replicateset options.
Long Form | Short Form | Meaning |
---|---|---|
--all | -a | Specifies that all servers defined for the replicate are checked. |
--allrepl | -A | Specifies that all replicates, whether they are
in a replicate set or not, are repaired. You cannot use the --replset option with the --allrepl option. |
--background | -B | Specifies that the operation is run in the background
as an SQL administration API command. The command and its result are stored in the command_history table in the sysadmin database, under the name that is specified by the --name= option, or the time stamp for the command if --name= is not specified. |
--checksum= | Specifies the name of an existing checksum function to use during consistency checking. By default, the checksum function that is provided with the database server is run. | |
--enable | -E | Enables replication on the target server if it was disabled by the cdr disable server command. |
--deletewins | -d | Specifies that the replicate uses the delete wins
conflict resolution rule. You cannot use this option for replicates that include TimeSeries columns. |
--excludeTimeSeries | Specifies to prevent the checking of time series data. | |
--extratargetrows= | -e | Specifies how to handle rows that are found on
the target servers that are not present on the server from which the
data is being copied (data_server):
|
--firetrigger= | -T | Specifies how to handle triggers at the target
servers while data is synchronizing:
|
--ignoreHiddenTSElements | Specifies to avoid checking time series elements that are marked as hidden. | |
--inprogress= | -i | Specifies to spend more than the default time to recheck inconsistent rows that might be in the process of being applied on target servers. If the --inprogress= option is not set, inconsistent rows are rechecked for up to five seconds. |
--master= | -m | Specifies the database server to use as the reference
copy of the data. You cannot use the --master option with the --timestamp option. |
--name= | -n | Specifies that the progress of this command can be monitored. Information about the operation is stored under the specified progress report task name on the server on which the command was run. |
--nomaster | -N | Specifies that the replicate is configured as a data consolidation system in which the multiple primary servers only send data and the single target server only receives data. |
--process= | -p | Specifies to run the command
in parallel, using the specified number of processes. At most, Enterprise
Replication can use one process for each replicate in the replicate
set. If you specify more processes than replicates, the extra processes
are not used. Not all replicates can be processed in parallel. For example, if replicates have referential integrity rules, the replicates with the parent tables must be processed before the replicates with the child tables. |
--repair | -R | Specifies that rows that are found to be inconsistent are repaired. |
--replset | -s | Specifies the name of the replicate set to check. You cannot use the --replset option with the --allrepl option. |
--skipLOB | -L | Specifies that large objects are not checked. |
--since= | -S | Specifies the time from which to check updated
rows. The replicate must be using the time stamp or delete wins conflict
resolution rule. You cannot use this option for replicates that include TimeSeries columns. |
--timeout= | -w | Specifies the time to wait for a disabled server to be enabled. |
--timestamp | -t | Specifies to repair inconsistent rows based on
the latest time stamp among all the participants. The replicate must
use the time stamp or delete wins conflict resolution rule. You cannot use the --master option with the --timestamp option. You cannot use this option for replicates that include TimeSeries columns. |
--verbose | -v | Specifies that the consistency report shows specific values that are inconsistent instead of a summary of inconsistent rows. |
Usage
Use the cdr check replicateset command to check the consistency of data between multiple database servers for a replicate set. The cdr check replicateset command compares all rows on all specified database servers against the data in the reference server and produces a consistency report. If you include the --verbose option, the report lists every inconsistent value; otherwise, the report summarizes inconsistent rows.
If you run this command as a DBSA instead of as user onedb, you must have INSERT, UPDATE, and DELETE permission on the replicated tables on all the replication servers in the domain.
If you want to monitor the progress of the check operation, include the --name option and specify a name for the progress report task. Then, run the cdr stats check command and specify the progress report task name.
Depending on the state of the data in your database when you run the cdr check command, the system might also run an UPDATE STATISTICS command.
If replicated transactions are active when the cdr check replicateset command is running, the consistency report might include rows that are temporarily inconsistent until those transactions are applied at the target server. By default, the cdr check replicateset command rechecks inconsistent rows for up to five seconds after the initial check is completed. If you find your transaction latency is longer than five seconds, you can extend the recheck time period by using the --inprogress option to specify a longer interval. After the initial recheck, inconsistent transactions are rechecked until there are no inconsistent transactions or the number of seconds specified by the --inprogress option elapses. In general, set the recheck time to a little longer than your average transaction latency because if repairing inconsistencies causes spooling in the send queue, transaction latency might increase during a repair. View your transaction latency with the cdr view apply command.
You can improve the performance of consistency checks by limiting the amount of data that is checked by using one or more of the following options:
- Skip the checking of large objects with the --skipLOB option. If you find that your large objects do not change as much as other types of data, then skipping them can make a consistency check quicker.
- Check from a specific time with the --since option. If the replicate uses the time stamp or delete wins conflict resolution rule and you regularly check consistency, you can limit the data that is checked to the data that was updated since the last consistency check.
You can significantly improve the performance of checking a replicate set by checking the member replicates in parallel. You specify the number of parallel processes with the --process option. For best performance, specify the same number of processes as the number of replicates in the replicate set. However, replicates with referential integrity constraints cannot be processed in parallel.
You can run a consistency check as a background operation as an SQL administration API command if you include the --background option. This option is useful if you want to schedule regular consistency checks with the Scheduler. If you run a consistency check in the background, provide a name for the progress report task by using the --name option so that you can monitor the check with the cdr stats check command. You can also view the command and its results in the command_history table in the sysadmin database. If you use the --background option as a DBSA, you must have CONNECT privilege on the sysadmin database and INSERT privilege on the ph_task table.
If you have large tables, you can speed consistency checking by indexing the ifx_replcheck shadow column.
If your replication system is configured for data consolidation and the primary servers include the S option in their participant definitions, you must include the --nomaster option.
The cdr check replicateset command repairs inconsistent rows so that they match the rows on the reference server. During a repair of inconsistent rows, the cdr check replicateset command uses direct synchronization as a foreground process when repairing inconsistent rows. The cdr check replicateset command with the --repair option performs the following tasks:
- Determines the order in which to repair tables if they have referential relationships.
- Creates a shadow replicate with the source server and target server as participants. The conflict resolution rule for the shadow replicate is always apply.
- Performs an index scan on the replication key index at both the source server and the target server to create a checksum and identify inconsistent rows.
- Replicates inconsistent rows from the source server to the target server by doing a dummy update of the source server, which might result in increased logging activity. Rows are not replicated to participants that include the S option in the participant definition because those participants only send data.
- Runs a check to determine whether any rows remain inconsistent. Rows can be temporarily inconsistent if not all transactions are complete on the target server.
- If any rows are inconsistent, reruns the check for up to five seconds, or for up to the number of seconds specified by the --inprogress option.
- Deletes the shadow replicate.
- Repeats steps 2 through 7 for each replicate in the replicate set.
- Displays the consistency report.
If you have disabled a server with the cdr disable server command, you can enable it and synchronize it by using the --enable option with the --repair option. You can optionally specify a timeout period with the --timeout option.
To repair all replicates, use the --allrepl option with the --repair option.
To repair replicate sets based on the latest time stamps among the participants instead of based on a master server, use the --repair option with the --timestamp option. If your replicates use the delete wins conflict resolution rule, also include the --deletewins option. A time stamp repair evaluates extra and mismatched rows according to the rules of the time stamp or delete wins conflict resolution rules.
You can run this command from within an SQL statement by using the SQL administration API.
Return codes
A return code of 0 indicates that the command was successful.
If the command is not successful, one of the following error codes is returned: 1, 5, 11, 17, 18, 31, 37, 48, 53, 54, 61, 75, 99, 101, 121, 166, 172, 174, 193, 194, 195, 200, 203, 204, 213.
For information about these error codes, see Return Codes for the cdr Utility
Example 1: Generate a consistency report
cdr check replicateset --master=g_serv1 --replset=replset_1 g_serv2 \
--process=2
Jan 17 2010 15:46:45 ------ Table scan for repl1 start --------
------ Statistics for repl1 ------
Node Rows Extra Missing Mismatch Processed
---------------- --------- --------- --------- --------- ---------
g_serv1 52 0 0 0 0
g_serv2 52 0 0 0 0
Jan 17 2010 15:46:55 ------ Table scan for repl1 end ---------
Jan 17 2010 15:46:46 ------ Table scan for repl2 start --------
------ Statistics for repl2 ------
Node Rows Extra Missing Mismatch Processed
---------------- --------- --------- --------- --------- ---------
g_serv1 48 0 0 0 0
g_serv2 48 0 0 0 0
Jan 17 2010 15:47:05 ------ Table scan for repl2 end ---------
This report indicates that the replicate set is consistent on these servers.
The consistency report for replicate sets shows a series of consistency reports for individual replicates that has the same format as the reports run with the cdr check replicate command.
Example 2: Enable and synchronize a replication server
The following command enables a replication server named g_serv2 and repairs inconsistencies by time stamp on all of its replicate sets:
cdr check replicateset --repair --enable\
--timestamp --allrepl g_serv2
The master server is not specified because the --timestamp option is used. The replicate set name is not specified because the --allrepl option is used.
Example 3: Repair inconsistencies based on time stamp
The following command repairs inconsistencies based on the most recent time stamps for all replicate on all replication servers:
cdr check replicateset --all --repair --timestamp --allrepl