Enhancements to Replication Definition Version in SAP Replication Server 15.7.1 SP303
SAP Replication Server 15.7.1 SP303 was released in March, 2016. Have you had a chance to try some of the new features? If not, review this post for a quick overview of several methods we introduced in SP303 to help you avoid and address issues caused by a missing replication definition version.
And here’s how it works …
- Lock the primary SAP ASE table by using the rs_send_repserver_cmd stored procedure
The proper way to modify a replication definition is to execute the rs_send_repserver_cmd stored procedure at the primary database with the primary table locked. In the past, you had to lock the primary table by using the corresponding database command. For example, if you want to modify the replication definition called authors for the primary SAP ASE table authorinfo, you need to run the following commands:
begin transaction
lock table authorinfo in exclusive mode
exec rs_send_repserver_cmd ‘alter replication definition authors drop zip’
commit tran
Now if you are working with a primary SAP ASE database, you can also lock the primary table with a new parameter called @ptable in this stored procedure. For instance, the following is equivalent to the above example.
exec rs_send_repserver_cmd ‘alter replication definition authors drop zip’, authorinfo
Locking the primary table when executing the rs_send_repserver_cmd stored procedure ensures the new replication definition version is created either before or after a transaction. This is especially important when there are large or long-running transactions on the primary database. If the replication definition is altered while the transaction is in progress, a replication definition version may be dropped from the system before the data associated with it can be processed by SAP Replication Server. This may result in the shutdown of the Data Server Interface (DSI). To avoid such issue, lock the primary table when you modify a replication definition.
Note that the @ptable parameter is available only when the primary database is SAP ASE. For other database types, please lock the primary table by using the corresponding database command as shown above. Just make sure the primary table is locked when you modify a replication definition at the primary database.
- Keep all replication definition versions
You might have already started wondering what if …
“Somehow I cannot lock the primary table when the replication definition commands are being executed.”
“I need to modify a replication definition directly within SAP Replication Server.”
Now you have another option, which is keeping all old versions in the system by using the new parameter, preserve_repdef_versions, in the configure replication server command within SAP Replication Server. For example,
Configure replication server
set preserve_repdef_versions to ‘on’
Set the value of the preserve_repdef_versions parameter to on to keep old replication definition versions in the system. This way, if you modify a replication definition, older versions are not deleted from the system unless you drop them manually.
- Drop a replication definition version
With the value of preserve_repdef_versions set to on, if you no longer need an old replication definition version, you need to remove it from your system by using the drop replication definition command.
For example, let’s drop the version 0x010100660000035f for the authors replication definition.
drop replication definition 0x010100660000035f for authors
- Create a replication definition version
If you forgot to lock the primary table when executing the rs_send_repserver_cmd stored procedure, or if you executed the alter replication definition command directly within SAP Replication Server without setting the value of preserve_repdef_versions to on, you might run into missing replication definition version issues. In this case, you can recreate the missing replication definition version:
create replication definition <repdef_version_id> for <replication_definition> as <repdef_version_id_to_be_copied>
Please don’t use this command to create the newest replication definition version, which is not allowed. The purpose of this command is to recreate replication definition versions dropped from the system while relevant data is still in the replication system.
- Alter the current replication definition so that the definition is identical to the missing replication definition version. For example:
alter replication definition authors add zip
This alteration creates a new version of the authors replication definition, which is 0x010400660000035f. This version of replication definition is identical to the missing version 0x010200660000035f.
- Recreate the missing version of 0x010200660000035f from the current version of 0x010400660000035f by using the new command as shown below.
create replication definition 0x010200660000035f for authors as 0x010400660000035f
The missing version 0x010200660000035f is recreated in the system.
- Reissue the command that failed due to the missing replication definition version. For example, resume the DSI connection.
- When the data associated with the version of 0x010200660000035f is no longer in the replication system, drop the version if necessary.
drop replication definition 0x010200660000035f for authors
- Alter the replication definition back to make it identical to the replication definition version before the alteration in step 1, which is 0x010300660000035f. For example:
alter replication definition authors drop zip
This alteration creates a new replication definition version of 0x010500660000035f. It should be identical to the version of 0x010300660000035f.
- View the creation date of a replication definition version
Run the rs_helprepversion command to review the creation date of a replication definition version to help you decide whether a particular version is old and can be safely removed from the system.
rs_helprepversion authors
go
Repdef Version Repdef Version Active Active Create
Name ID Inbound Outbound Date
————————————————– ——————————- ———– ————– —————————————–
Authors 0x0102006500000065 Yes Yes Feb 4 2016 2:53:25.157219PM
rs_drp010100650000006556b3d665 0x0101006500000065 No No Feb 4 2016 2:51:49.076000PM
rs_drp010000650000006556b3d605 0x0100006500000065 No No Feb 4 2016 2:50:57.716000PM
To summarize, always alter, drop, or create a replication definition at the primary database by executing the rs_send_repserver_cmd stored procedure with the primary table locked. Otherwise, set the value of the preserve_repdef_versions parameter to on within SAP Replication Server. If you fail to do both and run into an issue caused by a missing replication definition version, recreate it with the create replication definition command. For more information about the enhanced replication definition version, please check out the SAP Replication Server Reference Manual.
You can also find out more new features introduced in SAP Replication Server 15.7.1 SP303 in the Replication Server New Features Guide.
Great blog! Thanks for sharing!