The SharePlex commands configure, start, stop, control, and monitor the replication process. SharePlex commands are issued through the sp_ctrl interface.
The SharePlex commands configure, start, stop, control, and monitor the replication process. SharePlex commands are issued through the sp_ctrl interface.
Use the compare and compare using commands (collectively known as the comparison commands) to verify that a target table is in synchronization with its source table.
After running a comparison, you can run the repair or repair using command to repair any out-of-sync rows.
Note: A running comparison or repair does not affect the source tables in any way. SharePlex logs into the database only to query for read consistency, and the locks on the source tables are brief. SharePlex briefly locks the target tables during the processing, but users can continue accessing them with little or no awareness of the lock.
SharePlex can detect and repair out-of-sync rows in a target table that are caused by DML operations: INSERT, UPDATE, DELETE.
Compare/Repair can be executed on single or multiple instances that have the same Oracle client version, i.e., the same ORACLE_HOME.
SharePlex does not support (and will skip) the comparison and repair of the following:
If a table has a hash partition, comparing or repairing using the partition name is not supported. The user can use the table name instead. However, if the sub-partition is hash-based and the root partition is not, the user can use either the table name or the root partition name. (This limitation is applicable only for Oracle to PostgreSQL replication)
UDT inside VARRARY. Other UDTs are supported
Sequences
XML type with different storage on the source and target (CLOB on source, BINARY on target, or the other way around). Like to like Compare/Repair is supported.
VARRAY types not inside SDO_GEOMETRY or ST_GEOMETRY.
Do not perform DDL on a table that is being compared or repaired. A comparison does not detect out-of-sync conditions caused by DDL operations, including those that SharePlex supports. If the DDL changes the table definition, it invalidates the SELECT statement that is built by the comparison process to get the rows that need to be compared.
Once you correct an out-of-sync condition caused by DDL, you can use the repair command to resynchronize the data in the rows.
If multiple ORACLE_HOME directories with different Oracle versions are installed on the same machine, users can perform compare/repair operations only for the Oracle version that was used during the SharePlex configuration.
See the SharePlex Release Notes for additional information about data types that are supported by compare and compare using.
Network configurations in which a pass-through server is used to pass data between the source and target servers.
Comparisons and repairs are not supported in a cascading replication environment.
Comparison and repair command strings longer than 255 characters are not supported. This is an operating system limitation. To work around this limitation, use the edit command on the source system. You can type the command string within a text file, and then the command automatically executes the file.
Replication latency reduces the performance of compare and repair processing. The message from the source that spawns the comparison and repair processes on the target is sent through the queues with the replicated data. Delays caused by a data backlog also delay the spawn message and can cause the source process to lose its read consistency. If possible, perform comparisons and repairs during off-peak hours.
To repair a view, the following must be true:
(Applicable only for PostgreSQL source) To enhance the performance of the Compare process, SharePlex supports parallel hints via the SP_DEQ_PARALLELISM parameter, allowing you to specify the degree of parallelism, i.e., the number of worker processes to be launched.
By default, the PostgreSQL database optimizer selects the best-suited query execution plan for SQL statements, which may not be directly related to the degree of parallelism specified in the parallel hints. pg_hint_plan makes it possible to adjust execution plans using parallel hints each time a query is executed. SharePlex internally utilizes the pg_hint_plan extension if it is installed or configured in the database.
The example syntax to use parallel queries is as follows:
The pg_hint_plan extension supports the Parallel hint: Parallel(table <# of workers> [soft|hard])
SharePlex uses Parallel hints with hard parsing support: Parallel(table <# of workers> [hard])
When performing table-level partitioning on DATE or TIMESTAMP data types in Oracle to PostgreSQL comparisons, the NLS_CALENDAR parameter must be set to GREGORIAN on the Oracle database.
Note: The number of workers should be less than the CPU VCore of the database system.
If the Oracle table is set for replication to multiple targets that include Oracle and PostgreSQL (or other non-Oracle) targets, the compare command will stop with the message: "Oracle to multiple targets detected! Use 'at target' or 'to table' Compare/Repair options to select only one of its targets." (Applicable only for Oracle as a source)
It is expected that characters in the Oracle database are stored with the correct byte encoding, as per the character set specified in the NLS_CHARACTERSET (or NLS_NCHAR_CHARACTERSET for nchar, etc.). If the byte values are corrupted, Shareplex Compare/Repair will not be supported. For more information on setting NLS_LANG at the client or session level while inserting data into the DB, refer to https://docs.oracle.com/en/database/oracle/oracle-database/21/nlspg/setting-up-globalization-support-environment.html#GUID-372A5104-DC0A-41CA-B449-6AEC93F09C2E (Applicable only for Oracle as a source)
The following character sets are tested and supported for Oracle database as a source:
US7ASCII
UTF8
WE8ISO8859P1
AL16UTF16
AL32UTF8
The following scenarios require special handling when running a comparison.
Use case | Compare support |
---|---|
Consolidated replication |
Consolidated replication is supported if the target database and Post processes are configured to add the ID of the source host to each row. To compare or repair the correct rows in the central target table, use the targetwhere option and base the where clause on the source ID value. For example, to compare a table in the database at the Eastern headquarters of a company to the correct rows in the central corporate database, you could use a source ID of "East" for the Eastern database and then base the targetwhere clause on that value. Use the same targetwhere clause in the repair command. The comparison and repair processes can use the source ID value to select only the rows that are valid for the Eastern database. To use the comparison or repair commands for any implementation of consolidated replication, other than one that identifies a source ID, may result in the unwanted deletion of target rows. For more information about this configuration, see the SharePlex Administration Guide. You may need to combine the targetwhere option with the standard where option to ensure that the target rows are selected accurately. |
Peer-to-peer replication |
In a peer-to-peer configuration, you must decide which system is the trusted source system and which is the secondary, or target, system. The secondary system is the one where any repairs will be performed. Before you run a comparison or repair in a peer-to-peer environment, follow these steps:
For more information about this configuration, see the SharePlex Administration Guide. |
Tables without keys |
The comparison and repair commands issue a SELECT statement with an ORDER BY clause on the source and target systems. The ordering is faster if large tables have a primary key or a unique, non-null key and an index (preferably a unique index). Otherwise, all of the columns are used as a key. If a table has no unique row identifier, but does have one or more columns that can identify a row as unique, you can use the compare command with the orderby option. When this option is used, SharePlex prints a notice to the sp_xdesvr log on the source system that the command used those columns as a key. Limitation: Data inconsistency is likely to occur in replication or compare-repair processes when SharePlex replication involves tables containing non-key columns with duplicate data. |
Tables with extra source or target columns |
Use the compare command with the sourcewhere or targetwhere clause if the source or target table contains extra columns and those columns contain unique values on which to base the sorting. See Control which rows are compared. |
Compare operation on the XML data (applicable only for Oracle to Oracle) |
SharePlex displays the “ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT” error while performing the Compare operation on the XML data. Workaround:
|
Oracle table having LONG, BINARY_FLOAT, BINARY_DOUBLE, and NUMBER without any size. |
If SP_DEQ_USE_SP_CKSUM is set to 1, then the comparison is done by fetching values instead of calculating hashes using SQL queries, which is performance-taxing. CPU utilization is expected to spike depending on the table structure, row size, and row count. If an Oracle DB table contains LONG, BINARY_FLOAT, BINARY_DOUBLE, or NUMBER without precision data types, the comparison is done by fetching values by default due to limitations in calculating hashes for these data types in SQL queries. To avoid high resource utilization in such cases, users will need to skip these columns from the comparison. |
A comparison detects out-of-sync conditions in a target table that are caused by DML operations:
When you run the compare or compare using command on the source system, SharePlex initiates the following events:
If the row count passes the sanity check, the tables are compared as follows:
The compare and repair commands write the SQL that is needed to repair any out-of-sync rows to a SQL file in the same location as the log files. If only a compare command is issued, SharePlex does not execute these SQL statements. If a repair command is issued, the command works identically to the compare commands except that it executes the SQL statements to repair the out-of-sync rows.
You can suppress the output of the SQL log file. Some reasons to suppress this file are:
To suppress the SQL log file, use the nosqllog option with the compare or repair command.
To suppress the output of the SQL log file for all compare and repair runs while the current instance of SharePlex is running, set the SP_SYS_SECURE_MODE environment variable to 1. This variable must be set before starting SharePlex, so if the sp_cop process is running it must be restarted after setting this variable. When sp_cop is run with this environment variable, the compare and repair commands will not put data into SQL files and the Post process will not put data into the SharePlex error log.
All of the compare and repair commands enable you to run multiple processes concurrently.
A maximum of 20 SharePlex processes can use the post queue at the same time, including the replication processes and the comparison and repair processes. It is recommended that you allow a maximum of five comparison and repair processes to run at any given time. By using the compare using and repair using commands, you can work around the 20-process limit by comparing more tables per process.
If a comparison or repair fails because the limit is reached, SharePlex logs a message to the Event Log.
Note: You can run multiple commands more easily by using the edit command to edit a previous command to create a new one.
You can compare subsets of an active configuration file in the following ways.
To compare all of the tables in replication that belong to one schema, use the compare command with a wildcard:
sp_ctrl> compare scott.%
To compare all of the tables in a configuration file, use the compare using command:
sp_ctrl> compare using myconfig
To compare all of the tables in replication to one target route, use the compare using command with the at option:
Oracle: sp_ctrl> compare using config.active at prodsys@o.ora112
PostgreSQL: sp_ctrl> compare using config.active at prodsys@r.database_name
The compare and repair commands have where options that enable you to filter the rows that are selected for processing. By default, these commands affect all rows of a table and ignore columns in the target table that are not contained in the source table.
Use the where option to filter rows based on identically named columns in the source and target tables.
Use the sourcewhere and targetwhere options if one or more extra columns exists in either the source or target table and those rows contain values that determine row uniqueness.
To use this option correctly:
Use the standard where option for the other columns that have the same name on both source and target.
Important! If you plan to run both a comparison and repair for a target table that has extra rows, only use targetwhere to compare for UPDATEs and DELETEs. The repair command cannot determine the correct values for INSERTs. To work around this issue, set a default value for the extra columns or manually update the inserted rows.
Every time that a comparison or repair command is issued, the job ID is shown in the sp_ctrl display. If the sp_ctrl display is not available, you can view the job ID by running the compare status command.
To view the status or results of a comparison, use the compare status command in sp_ctrl.
For more information, see Compare status.
The sp_desvr and sp_declt processes write a log file on the system where they run. The logs are stored in the log sub-directory of the SharePlex variable-data directory.
The name of the log written by the sp_desvr process is xdesvr_<jobid>_r.<dbid>_p<process id>.log, where:
The names of the files written by the sp_declt process are xdeclt_<jobid>-<tableid>_r.<dbid>_p<processid>.log appended with either .log or .sql, where:
Example log file names:
xdesvr_7_r.aparopka_p4970.log
xdeclt_7-1_r.aparopka_p25095.log
xdeclt_7-1_r.aparopka_p25095_01.sql
To control disk usage, the logs are aged in a circular fashion. SharePlex generates a new log file when the current log reaches the size limit. New logs are created up to a maximum number of logs, and then SharePlex starts overwriting the oldest log.
The sp_xdesvr and sp_xdeclt processes write a log file on the system where they run. The logs are stored in the log sub-directory of the SharePlex variable-data directory.
The name of the log written by the sp_xdesvr process is xdesvr_<jobid>_r.<dbid>_p<process id>.log, where:
The names of the files written by the sp_xdeclt process are xdeclt_<jobid>-<tableid>_r.<dbid>_p<processid>.log appended with either .log or .sql, where:
Example log file names:
xdesvr_7_r.aparopka_p4970.log
xdeclt_7-1_r.aparopka_p25095.log
xdeclt_7-1_r.aparopka_p25095_01.sql
To control disk usage, the logs are aged in a circular fashion. SharePlex generates a new log file when the current log reaches the size limit. New logs are created up to a maximum number of logs, and then SharePlex starts overwriting the oldest log.
Note: For the compare using command, there rarely is more than one log file.
Use the cancel command to stop a running comparison or repair job.
sp_ctrl(sysA)>cancel JOBID
For more information, see Cancel.
SharePlex retains a history of each finished job in the database on the source system. The SP_SYS_JOB_HISTORY_RETENTION parameter controls how long history is retained.
To clear this history on demand, use the clear history command. When SharePlex removes the history of a job, it also removes the log file that was the source of the history.
To remove the log files from the source system without clearing the job history from the database, use the remove log command. You can also use this command to remove old log files from the target system.
To control the size of the log files, set the SP_DEQ_LOG_FILESIZE parameter.
To produce separate SQL files for INSERT, UPDATE, and DELETE operations, rather than use just one file for all operation types, use the log split option.
You can control the size of the block of rows that is fetched when the process makes its SELECT query. The block size is calculated based on the value set with the SP_DEQ_MALLOC parameter. The value is divided equally by the number of comparison threads to be used, and then it is recalculated based on the size of all of the columns added together.
Note: To repair out-of-sync rows found by the comparison, use the repair or repair using command. See Repair / repair using.
Supported source and target combinations: | Oracle to Oracle, Oracle to PostgreSQL, PostgreSQL to PostgreSQL |
Authorization level: | Operator (2) |
Issues on: | source system |
Related commands: | Repair / repair using |
Command | Command options | Remote options |
---|---|---|
compare owner.source_table[.partition] |
[ at target_host@o.target_sid ] | (applicable only for Oracle to Oracle) [ for o.source_sid ] | (applicable only for Oracle to Oracle) [ at target_host@r.target_db ] | (applicable only for PostgreSQL to PostgreSQL) [ for r.source_db ] | (applicable only for PostgreSQL to PostgreSQL) [ hint “hint” ] | [ for o.source_sid ] | (applicable only for Oracle to Oracle) [ {include | exclude} "column_list" ] | [ key ] | [ log rowdata ] | [ log split ] | [ {nolocksource | nolocktarget} ] | [ nosqllog ] | [ not "exception_list" ] | [ orderby "column_list” ] | [Override parameter to the compare and repair command] | [ parallelism degree ] | [ port port_number ] | [ quickcheck ] | [ sourcewhere “clause” ] | [ threads thread_count ] | [ targetwhere “clause” ] | [ totarget_owner.target_table[.partition] ] | [ where “clause” ] |
[ on host | on host:portnumber | on login/password@host | on login/password@host:portnumber ] |
compare using filename |
[key] | [log rowdata] | [log split] | [parallelism degree] | [port port_number] | [quickcheck] | [threads threads_count] |
[ on host | on host:portnumber | on login/password@host | on login/password@host:portnumber ] |
Required command components
Component | Description |
---|---|
compare owner.source_table[.partition] |
The basic command compares all of the source rows with all of the target rows. owner.source_table is the owner and name of the source table. Use double quotes to enforce case-sensitivity or spaces within a name, for example “HR”.emp. Wildcarded table names (but not owner names) are supported. To be compared, tables that satisfy a wildcard in this command must be listed (explicitly or by wildcard) in the active replication configuration. For more information about how SharePlex handles wildcards, see the SharePlex Administration Guide. Examples sp_ctrl(sysA)>compare scott.emp sp_ctrl(sysA)>compare scott.emp.west When running a comparison from the command line of the operating system, if the table name is case-sensitive, quoted strings must include an extra set of escaped double quotes. For example, if the table name is Dt_TOtalS1, the compare command should be: splex_install/bin/./sp_ctrl compare splex."\"Dt_TOtalS1\"" |
compare using filename |
The basic command compares all of the source rows with all of the target rows in the tables listed in filename. filename is the name of the file that contains the names of the source tables that you want to compare. Example sp_ctrl(sysA)>compare using sales |
Optional command components
Component | Description | |
---|---|---|
at target_host@o.target_sid (applicable only for Oracle to Oracle) |
Valid for compare Compares the source table to only one of its targets. Use when the source table replicates to multiple target systems. target_host is the name of the target system. target_sid is the ORACLE_SID of the target Oracle instance. Example sp_ctrl(SysA)>compare scott.emp at prod@o.prodsid | |
for o.SID (applicable only for Oracle to Oracle) |
Valid for compare Specifies the Oracle instance that contains the source table. Use when the same source table is in multiple Oracle instances on a system. SID is the ORACLE_SID of the source instance. It is case-sensitive and must be typed as it appears in the oratab file or V$PARAMETER table, or Windows Registry. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>compare scott.emp for o.oraA | |
at target_host@r.target_database_name (applicable only for PostgreSQL to PostgreSQL) |
Valid for compare Compares the source table to only one of its targets. Use when the source table replicates to multiple target systems. target_host is the name of the target system. target_db is the name of the target database name. Example sp_ctrl(SysA)>compare scott.emp at prod@r.database_name | |
for r.DBID (applicable only for PostgreSQL to PostgreSQL) |
Valid for compare Specifies the PostgreSQL instance that contains the source table. Use when the same source table is in multiple PostgreSQL instances on a system. DBID is the database name of the PostgreSQL source instance. It is case-sensitive and must be typed as it appears in the config file. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>compare scott.emp for r.database_name | |
hint "hint" (applicable only for Oracle to Oracle) |
Valid for compare Includes an Oracle hint in the SELECT statement. The hint is used on the source and target systems. “hint” is a standard Oracle hint no longer than 2000 characters. Enclose the entire hint within double quotes. Omit the leading /*+ and trailing */ in the hint string. They are added by SharePlex. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>compare scott.emp where “file >001005” hint “emp(salary)” When running a comparison from the command line of the operating system, quoted strings must have an extra set of escaped double quotes as in this example: /productdir/bin/sp_ctrl compare scott.emp hint “\“emp(salary)\””
| |
{include | exclude} "(column_list") |
Valid for compare Filters the columns to be compared.
(column_list) is the list of columns to include or exclude.
Note: There could still be rows that are out-of-sync in the columns that were not compared. Example sp_ctrl (SysA)>compare scott.emp exclude "color, weight" | |
key |
Valid for compare and compare using Performs a fast comparison of large tables. This command does not compare all of the data values. It compares one of the following:
Important: Even if the keys or the orderby values match, the tables remain out of synchronization if values in other columns do not match. When used, this option must appear after the required command arguments. It can appear in any order with other options. Do not use this option to base a comparison on a SharePlex key definition. For more information about SharePlex key definitions, see the SharePlex Administration Guide. Example sp_ctrl (SysA)>compare scott.emp key sp_ctrl(sysA)>compare using sales key | |
log rowdata |
Valid for compare and compare using Directs the client process to produce a SQL file that logs the actual row data rather than hash values. The file is produced on the target system. If the value of any of these data types is very large, SharePlex may not be able to log the actual data. IMPORTANT! The purpose of this SQL file is to provide a view of the data that was compared. Do not use it to repair target tables. The data values that were captured when the command was run may be different from those currently in the database. Use the repair command to repair any out-of-sync rows. Example sp_ctrl(sysA)>compare scott.emp log rowdata sp_ctrl(sysA)>compare using sales log rowdata | |
log split |
Valid for compare and compare using Directs the client process to split its SQL file into three different files based on the operation type: one for INSERTs, one for UPDATEs, and one for DELETEs. Example sp_ctrl(sysA)>compare scott.emp log split sp_ctrl(sysA)>compare using sales log split | |
{nolocktarget | nolocksource} |
Valid for compare Prevents the comparison process from locking tables during the comparison phase of a run that includes a repair. Normally, SharePlex locks the tables momentarily during a comparison to get a read-consistent view, and then unlocks them immediately, but SharePlex always locks target tables during a repair. SharePlex locks source tables momentarily during a repair to get a read-consistent view. Example sp_ctrl(sysA)>compare scott.emp nolocksource sp_ctrl(sysA)>compare scott.emp nolocktarget | |
nosqllog |
Suppresses output of the SQL log file. This file contains the SQL that is needed to repair out-of-sync rows. Some reasons not to output this file include:
| |
not “exception_list” |
Valid for compare Specifies an exception list of tables not to compare when the table specification includes wildcards. “exception_list” is a list of names of the tables not to compare.
Example sp_ctrl(SysA)>compare scott.% not (%temp%) | |
orderby “column_list” |
Valid for compare Specifies columns for the comparison process to use in its ORDERBY clause when it sorts rows to be compared. This option enables comparisons to be performed on tables that have no primary or unique key. “column_list” is the names of the columns to use in the ORDERBY clause.
Example sp_ctrl(SysA)>compare scott.emp where “file >001005” orderby “Last Name,Division” When running a comparison from the command line of the operating system, quoted strings must have an extra set of escaped double quotes: /productdir/bin/sp_ctrl compare scott.emp orderby “\“Last Name,Division\”” | |
override |
Valid for compare and compare using Overrides the sanity check and allows the comparison of tables that are out-of-sync beyond the sanity check threshold.Use an alternative method to re-sync the target table, similar to the initial process used for instantiating the target database/table. For more information about sanity check, see how the comparison works. Example: SP_ctrl (sysA) > compare scott.emp override SP_ctrl (sysA) > compare using sales override | |
port port_number (applicable only for Oracle to Oracle) |
Valid for compare and compare using Available for backward compatibility if the version of SharePlex is earlier than 8.0 on the source or target system. Specifies a port on the source system for the client process to use for communication with the server process. In earlier versions of SharePlex, the communication is two-way, and a random port number is selected by default for client-to-server communication. This option overrides the random port selection with a specific port number, such as that required by a firewall. Example sp_ctrl(sysA)>compare scott.emp port 1234 | |
quickcheck |
Valid for compare and compare using Performs an initial check to determine if any rows are out of synchronization. As soon as one out-of-sync row is detected, the process stops. No further information is returned. No out-of-sync row information is logged to the compare SQL file. Do not use this option with the key option or any of the where options. This option does not support LONG columns. Example sp_ctrl(sysA)>compare scott.emp quickcheck sp_ctrl(sysA)>compare using sales quickcheck | |
parallelism degree |
Valid for compare and compare using Adds a parallel hint to the SELECT statement. For degree, set the degree of parallelism. Example sp_ctrl(sysA)>compare scott.emp parallelism 4 sp_ctrl(sysA)>compare using sales parallelism 4 | |
sourcewhere “clause” |
Valid for compare Bases the comparison on one or more columns in the source table when those columns do not exist in the target table. Rows filtered by this condition on the source table will be locked.
Example #1: sp_ctrl(sysA)>compare scott.emp sourcewhere “file >001005” Example #2: The following example shows how the sourcewhere and where options are combined to get the desired result. Only the source comparison process will use the sourcewhere clause, but both the source and target comparison processes will use the where clause. sp_ctrl(SysA)>compare scott.emp sourcewhere “deptno = 200” where “mgr = ‘SMITH’” | |
targetwhere "clause" |
Valid for compare Bases the comparison on one or more columns in the target table when those columns do not exist in the source table. Rows filtered by this condition on the target table will be locked.
Example #1: sp_ctrl(SysA)> compare scott.emp targetwhere “file >001005” Example #2: The following example shows how the targetwhere and where options are combined to get the desired result. Only the target comparison process will use the targetwhere clause, but both the source and target comparison processes will use the where clause. sp_ctrl(SysA)>compare scott.emp where “deptno = 200” targetwhere “mgr = ‘SMITH’” repair | |
threads thread_count |
Valid for compare and compare using Sets the number of processing threads that are used by the comparison process. Example sp_ctrl(sysA)>compare scott.emp threads 4 sp_ctrl(sysA)>compare using sales threads 4 | |
to target_owner.target_table[.partition] |
Valid for compare Compares the source table to only one of its targets. Use when the source table replicates to multiple target systems and the target tables have different names. This option can also be used to specify a target partition. compare source_owner.source_table.[source_partition] to target_owner.target_table.[target_partition] Example (Compares a partition) sp_ctrl(SysA)>compare scott.emp.east to scott.allemp.alleast | |
where “clause” |
Valid for compare Include a WHERE clause in the SELECT statement on both the source and target systems. The WHERE clause acts as a filter to compare specific rows. Rows filtered by this condition will be locked. For “clause” specify a standard WHERE clause that does not include subqueries.
Example sp_ctrl (SysA)>compare scott.emp where “region=4” |
These options enable you to issue the command on a remote machine and to script commands that include a login name, password, port number, or combination of those items.
Option | Description |
---|---|
on host |
Execute the command on a remote system (one other than the one where the current sp_ctrl session is running). You are prompted for login credentials for the remote system. If used, must be the last component of the command syntax. Example: sp_ctrl(sysB)>status on SysA |
on host:portnumber |
Execute the command on a remote system when a remote login and port number must be provided. If used, must be the last component of the command syntax. Example: sp_ctrl(sysB)>status on SysA:8304 |
on login/password@host |
Execute the command on a remote system when a remote login, password, and host name must be provided. If used, must be the last component of the command syntax. Example:sp_ctrl(sysB)>status on john/spot5489@SysA |
on login/password@host:portnumber |
Execute the command on a remote system when a remote login, password, host name, and port number must be provided. If used, must be the last component of the command syntax. Example: sp_ctrl(sysB)>status on john/spot5489@SysA:8304 |
Use the repair and repair using commands (collectively known as the repair commands) to repair out-of-sync rows in a target table or tables.
The repair commands first perform a comparison to identify the rows that need to be repaired, and then they perform the repair. For more information about how tables are compared, see Compare / compare using.
Note: A running comparison or repair does not affect the source tables in any way. SharePlex logs into the database only to query for read consistency, and the locks on the source tables are brief. SharePlex briefly locks the target tables during the processing, but users can continue accessing them with little or no awareness of the lock. Target table (or Out-Of-Sync rows if less than threshold value) is locked during the repair process to correct any Out-of-Sync rows.
SharePlex can detect and repair out-of-sync rows in a target table that are caused by DML operations: INSERT, UPDATE, DELETE.
Compare/Repair can be executed on single or multiple instances that have the same Oracle client version, i.e., the same ORACLE_HOME.
SharePlex does not support (and will skip) the comparison and repair of the following:
If a table has a hash partition, comparing or repairing using the partition name is not supported. The user can use the table name instead. However, if the sub-partition is hash-based and the root partition is not, the user can use either the table name or the root partition name. (This limitation is applicable only in Oracle to PostgreSQL replication)
Do not perform DDL on a table that is being compared or repaired. A comparison does not detect out-of-sync conditions caused by DDL operations, including those that SharePlex supports. If the DDL changes the table definition, it invalidates the SELECT statement that is built by the comparison process to get the rows that need to be compared.
Once you correct an out-of-sync condition caused by DDL, you can use the repair command to resynchronize the data in the rows.
Network configurations in which a pass-through server is used to pass data between the source and target servers.
Comparisons and repairs are not supported in a cascading replication environment.
Comparison and repair command strings longer than 255 characters are not supported. This is an operating system limitation. To work around this limitation, use the edit command on the source system. You can type the command string within a text file, and then the command automatically executes the file.
See the SharePlex Release Notes for additional information about data types that are supported by compare and compare using
Replication latency reduces the performance of compare and repair processing. The message from the source that spawns the comparison and repair processes on the target is sent through the queues with the replicated data. Delays caused by a data backlog also delay the spawn message and can cause the source process to lose its read consistency. If possible, perform comparisons and repairs during off-peak hours.
To repair a view, the following must be true:
If the Oracle table is set for replication to multiple targets that include Oracle and PostgreSQL (or other non-Oracle) targets, the compare command will stop with the message: "Oracle to multiple targets detected! Use 'at target' or 'to table' compare/repair options to select only one of its targets."
When performing table-level partitioning on DATE or TIMESTAMP data types in Oracle to PostgreSQL comparisons, the NLS_CALENDAR parameter must be set to GREGORIAN on the Oracle database.
It is expected that characters in the Oracle DB are stored with the correct byte encoding, as per the character set specified in the NLS_CHARACTERSET (or NLS_NCHAR_CHARACTERSET for nchar, etc.). If the byte values are corrupted, Shareplex compare/repair will not be supported. For more information on setting NLS_LANG at the client or session level while inserting data into the DB, refer to https://docs.oracle.com/en/database/oracle/oracle-database/21/nlspg/setting-up-globalization-support-environment.html#GUID-372A5104-DC0A-41CA-B449-6AEC93F09C2E
The following character sets are tested and supported for Oracle database as a source:
US7ASCII
UTF8
WE8ISO8859P1
AL16UTF16
AL32UTF8
The recommended procedure for maintaining synchronized data through the comparison and repair commands is to run the compare or compare using command first, then view the results with the repair status command. This command shows any rows that are out-of-sync and the possible cause. Unless the cause of the out-of-sync condition is corrected, replication will go out of synchronization again, even if you repair the rows this time. After the problem is fixed, issue the repair or repair using command.
You can run the repair or repair using command without doing a preliminary comparison. The command performs a comparison first, to identify the out-of-sync rows, and then it repairs those rows. However, the underlying cause of the out-of-sync condition must be corrected to prevent future out-of-sync conditions.
See
The best time to repair a target table depends on its size, the cause of the problem, the extent of out-of-sync rows, and how long you are willing to tolerate users being locked out. Before you initiate a repair, consider the following:
If you must repair a table immediately, but cannot tolerate locks or replication latency, you can use the where option to limit the repair to certain rows. An alternative is to use the key option, but this option may cause the repair to miss some out-of-sync rows.
The following scenarios require special handling when running a comparison.
Use case | Compare support |
---|---|
Consolidated replication |
The target table in a central database has more rows than any of its contributing source databases, and often it has more columns than the source databases. Special consideration is required when using the repair commands in this environment. repair using command Consolidated replication is not supported by the repair using command. The repair using command will cause unwanted deletion of target rows that do not exist in those source tables. As a workaround, create a subset of the configuration that excludes the tables that are involved in consolidated replication, and repair the subset configuration instead. You can use the repair command to repair the tables that are involved in consolidated replication. repair command Consolidated replication is supported if the target database and Post processes are configured to add the ID of the source host to each row. To compare or repair the correct rows in the central target table, use the targetwhere option and base the where clause on the source ID value. For example, to compare a table in the database at the Eastern headquarters of a company to the correct rows in the central corporate database, you could use a source ID of "East" for the Eastern database and then base the targetwhere clause on that value. Use the same targetwhere clause in the repair command. The comparison and repair processes can use the source ID value to select only the rows that are valid for the Eastern database. The use the comparison or repair commands for any implementation of consolidated replication, other than one that identifies a source ID, may result in the unwanted deletion of target rows. For more information about this configuration, see the SharePlex Administration Guide. You may need to combine the targetwhere option with the standard where option to ensure that the target rows are selected accurately. |
Peer-to-peer replication |
In a peer-to-peer configuration, you must decide which system is the trusted source system and which is the secondary, or target, system. The secondary system is the one where any repairs will be performed. Before you run a comparison or repair in a peer-to-peer environment, follow these steps:
For more information about this configuration, see the SharePlex Administration Guide. |
Tables without keys |
The comparison and repair commands issue a SELECT statement with an ORDER BY clause on the source and target systems. The ordering is faster if large tables have a primary key or a unique, non-null key and an index (preferably a unique index). Otherwise, all of the columns are used as a key. If a table has no unique row identifier, but does have one or more columns that can identify a row as unique, you can use the compare command with the orderby option. When this option is used, SharePlex prints a notice to the sp_xdesvr (PostgreSQL) or the sp_desvr(Oracle) log on the source system that the command used those columns as a key. The columns considered as keys should not contain null values if a repair needs to be done for a single row; it may result in a repair error. In this case, use the orderby option with columns that uniquely identify that row and do not contain null values. Limitation: Data inconsistency is likely to occur in replication or compare-repair processes when SharePlex replication involves tables containing non-key columns with duplicate data. |
Target tables with more columns than the source table |
The repair and repair using commands ignore target columns that are not contained in the source table. A repair does the following:
|
Tables with a UNIQUE constraint |
Columns defined with a UNIQUE constraint can cause the repair or repair using command to return unique-constraint violation errors. The following example shows source and target tables with two columns each. The first column is the primary key, and the second column has the UNIQUE constraint.
When SharePlex attempts to repair row 1 of the target table to match the source, the UNIQUE constraint on column 2 returns an error because the value 'ABC' already exists in row 2. The same thing happens for row 2 of the target table, because 'XYZ' already exists in row 1. Workarounds are:
|
Tables with LOB columns |
Repairs take longer if any target tables have LOB columns. For a faster repair, you can set the SP_DEQ_SKIP_LOB parameter to 0 so that the LOB columns are skipped in the comparison and repair. For more information, see SP_DEQ_SKIP_LOB . |
Repair operation on the XML data (valid only for Oracle to Oracle replication) |
SharePlex displays the “ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT” error while performing the Repair operation on the XML data. Workaround:
|
A repair repairs out-of-sync conditions in a target table that are caused by DML operations:
The repair and repair using commands issue the following corrective SQL statements:
A repair always includes a comparison to locate the out-of-sync conditions in a target table.
When you run the repair or repair using command, SharePlex initiates the following sequence of events:
The row selection and repair proceeds as follows:
Target tables are locked when it is their turn to be repaired, and then the lock is released.
If SharePlex encounters a database error when it applies a repair SQL statement, it stops the repair from that statement forward and commits only the previously applied valid statements. Thus, the table is partially repaired, but it still could be out of synchronization. The repair status command alerts you to this situation.
The compare and repair commands write the SQL that is needed to repair any out-of-sync rows to a SQL file in the same location as the log files. If only a compare command is issued, SharePlex does not execute these SQL statements. If a repair command is issued, the command works identically to the compare commands except that it executes the SQL statements to repair the out-of-sync rows.
You can suppress the output of the SQL log file. Some reasons to suppress this file are:
To suppress the SQL log file, use the nosqllog option with the compare or repair command.
To suppress the output of the SQL log file for all compare and repair runs while the current instance of SharePlex is running, set the SP_SYS_SECURE_MODE environment variable to 1. This variable must be set before starting SharePlex, so if the sp_cop process is running it must be restarted after setting this variable. When sp_cop is run with this environment variable, the compare and repair commands will not put data into SQL files and the Post process will not put data into the SharePlex error log.
All of the compare and repair commands enable you to run multiple processes concurrently.
A maximum of 20 SharePlex processes can use the post queue at the same time, including the replication processes and the comparison and repair processes. It is recommended that you allow a maximum of five comparison and repair processes to run at any given time. By using the compare using and repair using commands, you can work around the 20-process limit by comparing more tables per process.
If a comparison or repair fails because the limit is reached, SharePlex logs a message to the Event Log.
Note: You can run multiple commands more easily by using the edit command to edit a previous command to create a new one.
You can repair subsets of an active configuration in the following ways.
To repair all of the target tables in replication that belong to one schema, use the repair command with a wildcard:
sp_ctrl> repair scott.%
To repair all of the target tables in a configuration file, use the repair using command:
sp_ctrl> repair using myconfig
To repair all of the target tables in one target route, use the repair using command with the at option:
sp_ctrl> repair using config.active at prodsys@o.ora112 (Oracle source)
sp_ctrl> repair using config.active at prodsys@r.dbid (PostgreSQL source)
The compare and repair commands have where options that enable you to filter the rows that are selected for processing. By default, these commands affect all rows of a table and ignore columns in the target table that are not contained in the source table.
Use the where option to filter rows based on identically named columns in the source and target tables.
Use the sourcewhere and targetwhere options if one or more extra columns exists in either the source or target table and those rows contain values that determine row uniqueness.
To use this option correctly:
Use the standard where option for the other columns that have the same name on both source and target.
Important! If you plan to run both a comparison and repair for a target table that has extra rows, only use targetwhere to compare for UPDATEs and DELETEs. The repair command cannot determine the correct values for INSERTs. To work around this issue, set a default value for the extra columns or manually update the inserted rows.
Every time that a comparison or repair command is issued, the job ID is shown in the sp_ctrl display. If the sp_ctrl display is not available, you can view the job ID by running the compare status command.
To view the status or results of a repair, use the repair status command in sp_ctrl.
For more information, see Repair status.
The sp_desvr and sp_declt processes write a log file on the system where they run. The logs are stored in the log sub-directory of the SharePlex variable-data directory.
The name of the log written by the sp_desvr process is desvr_JobID_SID_pProcessID.log, where:
The names of the files written by the sp_declt process are declt_JobIDTableID_SID_SourceHost_pProcessID appended with either .log or .sql, where:
Example log file names:
desvr_606_ora112_p14610.log
declt_606-1_ora112_prodsys_p6528.log
declt_606-1_ora112_prodsys_p6528.sql
To control disk usage, the logs are aged in a circular fashion. SharePlex generates a new log file when the current log reaches the size limit. New logs are created up to a maximum number of logs, and then SharePlex starts overwriting the oldest log.
The sp_xdesvr and sp_xdeclt processes write a log file on the system where they run. The logs are stored in the log sub-directory of the SharePlex variable-data directory.
The name of the log written by the sp_xdesvr process is xdesvr_<jobid>_r.<dbid>_p<process id>.log, where:
The names of the files written by the sp_xdeclt process are xdeclt_<jobid>-<tableid>_r.<dbid>_p<processid>.log appended with either .log or .sql, where:
Example log file names:
xdesvr_7_r.aparopka_p4970.log
xdeclt_7-1_r.aparopka_p25095.log
xdeclt_7-1_r.aparopka_p25095_01.sql
To control disk usage, the logs are aged in a circular fashion. SharePlex generates a new log file when the current log reaches the size limit. New logs are created up to a maximum number of logs, and then SharePlex starts overwriting the oldest log.
Use the cancel command to stop a running comparison or repair job.
sp_ctrl(sysA)>cancel JOBID
For more information, see Cancel.
SharePlex retains a history of each finished job in the database on the source system. The SP_SYS_JOB_HISTORY_RETENTION parameter controls how long history is retained.
To clear this history on demand, use the clear history command. When SharePlex removes the history of a job, it also removes the log file that was the source of the history.
To remove the log files from the source system without clearing the job history from the database, use the remove log command. You can also use this command to remove old log files from the target system.
To control the size of the log files, set the SP_DEQ_LOG_FILESIZE parameter.
You can control the size of the block of rows that is fetched when the process makes its SELECT query. The block size is calculated based on the value set with the SP_DEQ_MALLOC parameter. The value is divided equally by the number of comparison threads to be used, and then it is recalculated based on the size of all of the columns added together.
Supported source and target combinations: | Oracle to Oracle, PostgreSQL to PostgreSQL, Oracle to PostgreSQL |
Authorization level: | Operator (2) |
Issues on: | source system |
Related commands: | Compare / compare using |
Basic commands | Command options | Remote options |
---|---|---|
repair owner.source_table[.partition] |
[ at target_host@o.target_sid ] | (applicable only for Oracle to Oracle) [ for o.source_sid ] | (applicable only for Oracle to Oracle) [hint “hint”] | (applicable only for Oracle to Oracle) [ at target_host@r.target_dbid ] | (PostgreSQL command option) [ for r.source_dbid ] | (PostgreSQL command option) [ {include | exclude} "column_list" ] | [ insertonly ] | [ key ] | [ nosqllog ] | [ not "exception_list" ] | [ onepass ] | [ orderby "column_list” ] | [ parallelism degree ] | [ portport_number ] | (applicable only for Oracle to Oracle) [ sourcewhere “clause” ] | [ threads thread_count ] | [ targetwhere “clause” ] | [ to target_owner.target_table[.partition] ] | [ where “clause” ] |
[ on host | on host:portnumber | on login/password@host | on login/password@host:portnumber ] |
repair using filename |
[ key ] | [ onepass ] | [ port port_number ] | [ threads threads_count ] | [ parallelism degree ] |
[ on host | on host:portnumber | on login/password@host | on login/password@host:portnumber ] |
Component | Description |
---|---|
repair owner.source_table[.partition] |
The basic command repairs all of the source rows with all of the target rows. owner.source_table is the owner and name of the source table. Use double quotes to enforce case-sensitivity or spaces within a name, for example “HR”.emp. Wildcarded table names (but not owner names) are supported. To be repaired, tables that satisfy a wildcard in this command must be listed (explicitly or by wildcard) in the active replication configuration. For more information about how SharePlex handles wildcards, see the SharePlex Administration Guide. Example sp_ctrl(sysA)>repair scott.emp When running a repair from the command line of the operating system, if the table name is case-sensitive, quoted strings must include an extra set of escaped double quotes. For example, if the table name is Dt_TOtalS1, the repair command should be: splex_install/bin/./sp_ctrl repair splex."\"Dt_TOtalS1\"" |
repair using filename |
The basic command repairs all of the out-of-sync rows in the target tables listed in filename. filename is the name of the file that contains the names of the source tables whose targets you want to repair. Example sp_ctrl(sysA)>repair using sales |
Component | Description | |
---|---|---|
at target_host@o.target_sid (applicable only for Oracle to Oracle) |
Valid for repair Repairs only one of the target tables in a configuration where the source table replicates to multiple target systems. target_host is the name of the target system. target_sid is the ORACLE_SID of the target Oracle instance. Example sp_ctrl(SysA)>repair scott.emp at prod@o.prodsid | |
for o.SID (applicable only for Oracle to Oracle) |
Valid for repair Specifies the Oracle instance that contains the source table. Use when the same source table is in multiple Oracle instances on a system. SID is the ORACLE_SID of the source instance. It is case-sensitive and must be typed as it appears in the oratab file or V$PARAMETER table, or Windows Registry. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>repair scott.emp for o.oraA | |
at target_host@r.target_database_name (applicable only for PostgreSQL to PostgreSQL) |
Valid for repair Repairs only one of the target tables in a configuration where the source table replicates to multiple target systems. target_host is the name of the target system. target_db is the name of the target database name. Example sp_ctrl(SysA)>compare scott.emp at prod@r.database_name | |
for r.DBID (applicable only for PostgreSQL to PostgreSQL) |
Valid for compare Specifies the PostgreSQL instance that contains the source table. Use when the same source table is in multiple PostgreSQL instances on a system. DBID is the database name of the PostgreSQL source instance. It is case-sensitive and must be typed as it appears in the config file. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>compare scott.emp for r.database_name | |
{include | exclude} "(column_list)" |
Valid for repair Filters the columns to be repaired.
(column_list) is the list of columns to include or exclude.
Note: There could still be rows that are out-of-sync in the columns that were not repaired. Example sp_ctrl (SysA)>repair scott.emp exclude "color, weight" | |
hint "hint" (applicable only for Oracle to Oracle) |
Valid for repair Includes an Oracle hint in the SELECT statement. The hint is used on the source and target systems. “hint” is a standard Oracle hint no longer than 2000 characters. Enclose the entire hint within double quotes. Omit the leading /*+ and trailing */ in the hint string. They are added by SharePlex. When used, this option must appear after the required command arguments, but it can appear in any order with other options. Example sp_ctrl (SysA)>repair scott.emp where “file >001005” hint “emp(salary)” When running a repair from the command line of the operating system, quoted strings must have an extra set of escaped double quotes: /productdir/bin/sp_ctrl repair scott.emp hint “\“emp(salary)\””
| |
insertonly |
Valid for repair Repairs the target table for INSERT statements only. Example: sp_ctrl(SysA)>repair scott.emp insertonly | |
key |
Valid for repair and repair using Performs a fast compare and repair of large tables. This command does not compare all of the data values, but only compares one of the following:
If the key or orderby columns do not match, SharePlex repairs the entire row by deleting it and then inserting it again based on the source values. Important! Use this option with caution. Even if key values match, it is possible for values in non-key columns to be out of synchronization. When used, this option must appear after the required command arguments. It can appear in any order with other options. Do not use this option to base a repair on a SharePlex key definition. For more information about SharePlex key definitions, see the SharePlex Administration Guide. Example sp_ctrl (SysA)>repair scott.emp key sp_ctrl(sysA)>repair using sales key | |
nosqllog |
Suppresses output of the SQL log file. This file contains the SQL that is needed to repair out-of-sync rows. Some reasons not to output this file include:
| |
not “exception_list” |
Valid for repair Specifies an exception list of tables not to repair when the table specification includes wildcards. “exception_list” is a list of names of the tables not to repair.
Example sp_ctrl(SysA)>repair scott.% not (%temp%) | |
onepass |
Valid for repair and repair using Use this option to run a compare and repair concurrently. Use it for large out-of-sync tables. Normally, a repair runs in two passes: first a compare, then a repair, which locks the target table. Both passes require a consistent view. With onepass, the target table is locked and repaired as soon as the compare client receives the consistent view marker. Example sp_ctrl(SysA)>repair scott.emp onepass
| |
orderby “column_list” |
Valid for repair Use the ORDERBY clause command option in conjunction with the KEY command option to compare the columns specified with the ORDERBY option. If the key or ORDERBY columns do not match, SharePlex repairs the entire row by deleting it and then inserting it again based on the source values. Specifies columns for the repair process to use in its ORDERBY clause when it sorts rows to be compared. This option enables repairs to be performed on tables that have no primary or unique key. “column_list” is the names of the columns to use in the ORDERBY clause.
Example sp_ctrl(SysA)>repair scott.emp where “file >001005” orderby “Last Name,Division” | |
parallelism degree |
Valid for repair and repair using Adds a parallel hint to the SELECT statement. For degree, set the degree of parallelism. Example sp_ctrl(sysA)>repair scott.emp parallelism 4 sp_ctrl(sysA)>repair using sales parallelism 4 | |
port port_number (applicable only for Oracle to Oracle) |
Valid for repair and repair using Available for backward compatibility if the version of SharePlex is earlier than 8.0 on the source or target system. Specifies a port on the source system for the client process to use for communication with the server process. In earlier versions of SharePlex, the communication is two-way, and a random port number is selected by default for client-to-server communication. This option overrides the random port selection with a specific port number, such as that required by a firewall. Example sp_ctrl(sysA)>compare scott.emp port 1234 | |
sourcewhere “clause” |
Valid for repair Bases the repair on one or more columns in the source table when those columns do not exist in the target table. Rows filtered by this condition on the source table will be locked.
Example #1: sp_ctrl(sysA)>repair scott.emp sourcewhere “file >001005” Example #2: The following example shows how the sourcewhere and where options are combined to get the desired result. Only the source repair process uses the sourcewhere clause, but both the source and target repair processes use the where clause. sp_ctrl(SysA)>repair scott.emp sourcewhere “deptno = 200” where “mgr = ‘SMITH’” | |
targetwhere "clause" |
Valid for repair Bases the repair on one or more columns in the target table when those columns do not exist in the source table. Rows filtered by this condition on the target table will be locked.
Example #1: sp_ctrl(SysA)> repair scott.emp targetwhere “file >001005” Example #2: The following example shows how the targetwhere and where options are combined to get the desired result. Only the target repair process will use the targetwhere clause, but both the source and target repair processes will use the where clause. sp_ctrl(SysA)>repair scott.emp where “deptno = 200” targetwhere “mgr = ‘SMITH’” repair | |
threads thread_count |
Valid for repair and repair using Sets the number of processing threads that are used by the repair process. Example sp_ctrl(sysA)>repair scott.emp threads 4 sp_ctrl(sysA)>repair using sales threads 4 | |
to target_owner.target_table [.partition] |
Valid for repair Repairs only one of the targets of a source table. Use when the source table replicates to multiple target systems and the target tables have different names. This option can also be used to specify a target partition. compare source_owner.source_table.[source_partition] to target_owner.target_table.[target_partition] Example (Repairs a partition) sp_ctrl(SysA)>repair scott.emp.east to scott.allemp.alleast | |
where “clause” |
Valid for repair Include a WHERE clause in the SELECT statement on both the source and target systems. The WHERE clause acts as a filter to repair specific rows. Rows filtered by this condition will be locked. For “clause” specify a standard WHERE clause that does not include subqueries.
Example sp_ctrl (SysA)>repair scott.emp where “region=4” |
These options enable you to issue the command on a remote machine and to script commands that include a login name, password, port number, or combination of those items.
Option | Description |
---|---|
on host |
Execute the command on a remote system (one other than the one where the current sp_ctrl session is running). You are prompted for login credentials for the remote system. If used, must be the last component of the command syntax. Example:sp_ctrl(sysB)>status on SysA |
on host:portnumber |
Execute the command on a remote system when a remote login and port number must be provided. If used, must be the last component of the command syntax. Example:sp_ctrl(sysB)>status on SysA:8304 |
on login/password@host |
Execute the command on a remote system when a remote login, password, and host name must be provided. If used, must be the last component of the command syntax. Example:sp_ctrl(sysB)>status on john/spot5489@SysA |
on login/password@host:portnumber |
Execute the command on a remote system when a remote login, password, host name, and port number must be provided. If used, must be the last component of the command syntax. Example:sp_ctrl(sysB)>status on john/spot5489@SysA:8304 |
The SharePlex utilities help you configure, test, and manage the SharePlex environment.
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center