Simulate Atomic Materialization

Use simulate atomic materialization as a bulk materialization method when you cannot suspend updates to the primary database.

This method ensures replicated data consistency by retrieving the subscription data, activating the subscription, and suspending the DSI connection to the replicate database all in one transaction at the primary data server.

  1. Verify that the entire replication system is working.
    See Replication Server Administration Guide Volume 2 > Verify and Monitor Replication Server.
  2. Execute the define subscription command at the replicate Replication Server.
  3. Wait for the subscription to be defined at both the primary and replicate Replication Servers. Execute the check subscription command at both the primary and replicate Replication Servers to verify that the subscription status is DEFINED.
  4. Activate the subscription by executing a single transaction as shown in this sample transaction that includes select with holdlock and the rs_marker stored procedure.
    begin transaction
    select from table with holdlock
    where search_conditions
    execute rs_marker
    'activate subscription subid 
    with suspension'
    commit transaction

    subid is an integer that identifies the subscription. The subid for a subscription can be found in the subid field of the rs_subscriptions system table in the RSSD. After the subscription is defined, you can find its subid by executing the following query in the RSSD of the primary or replicate Replication Server:

    select subid from rs_subscriptions
    where subname = 'subscription'
    and dbid in (select connid from rs_databases
    where dbname = 'rep_connection_dbname'
    and dsname = 'rep_connection_dsname')

    where rep_connection_dbname and rep_connection_dsname can be for the default or alternate connections.

  5. Wait for the subscription to become active at both the primary and replicate Replication Servers. Execute the check subscription command at the replicate Replication Server to verify that the subscription status is ACTIVE. When the subscription status is ACTIVE at the replicate Replication Server, the database connection for the replicate database has been suspended.
  6. As soon as the subscription becomes active at the primary Replication Server, retrieve the data from the primary database using a select or a database dump.
  7. Find the ID number (subid) for the subscription by querying the rs_subscriptions system table.
    select subid from rs_subscriptions
    where subname = 'subscription'
    and dbid in (select connid from rs_databases
    where dbname = 'rep_connection_dbname'
    and dsname = 'rep_connection_dsname')
  8. Execute the rs_marker stored procedure in the primary database:
    rs_marker 'validate subscription subid'
    Warning!  Be sure that you execute the rs_marker stored procedure with the correct subid number for the subscription. The subid column in the rs_subscriptions system table contains the unique ID number for each subscription. Entering any other number or character string may cause serious problems.

    For more information on rs_marker see Replication Server Reference Manual.

  9. Load the subscription data into the replicate database.
  10. Enable autocorrection for the replication definition at the replicate database.
  11. Use the resume connection command to resume the database connection for the replicate database.
  12. Wait for the subscription to become valid at both the primary and replicate Replication Servers. Execute the check subscription command at the replicate Replication Server to verify that the subscription status is VALID. Once the subscription status is VALID, the replicate data is consistent with the primary data.
  13. Disable autocorrection for the replicate database.

Now the subscription is created and replication is active.

Related concepts
Autocorrection for Nonatomic Materialization
Related tasks
Replicating Tables in the Example Replication System