Enabling Loop Detection

If a table is used as both a source table and a destination table for the same subject, a loop occurs and the same changes are published repeatedly. To prevent this issue, you can enable the loop detection feature by selecting the Enable Loop Detection check box in the Publication Options tab.

If the loop detection feature is enabled, an additional column, ADB_SOURCE, is added to the source table. When the adapter receives a message, it inserts or updates a row into the source table and enters a T in the ADB_SOURCE column to denote that this row was inserted or updated according to the received message, rather than user intervention.

Triggers created by the adapter are defined not to copy the rows with T in the ADB_SOURCE column to the publishing table, which means that the rows will not be published. If you must update a received row (that is, has a T in the ADB_SOURCE column) and want the updated row published, you have to change the ADB_SOURCE column to NULL, and then the trigger retrieves the row and sends it.

Note: Loop detection is disabled for DB2 on z/OS because DB2 on z/OS does not support the drop column feature.

Master-Master Replication

You can use the loop detection feature to implement a simple master-master replication scheme. When master-master replication is implemented, multiple sites act as peers to copy and maintain groups of replicated objects.

When loop detection is enabled, the adapter can be configured as both a Publisher endpoint and a Subscriber endpoint to the same table on the same subject. When the Subscriber endpoint receives a message, it compares the adapter ID of the message with its own adapter ID. If the values of the adapter IDs are the same, and the source and destination tables are the same table in the database, the Subscriber endpoint discards the message. Other Subscriber endpoints listening on the subject receive the message only once.

The adapter does not resolve any replication conflicts, for example, two applications updating the same row of their corresponding source table both publish the change. Regarding advanced replication scenarios, use the replication tools provided by your database vendor.