This page describes the original 2016 WCF-based design of Database Mirroring, where SuperOffice pushed data to a partner-hosted endpoint that implemented
IMirrorClientService. That design is now legacy.The current implementation is an outbound-only client that the customer runs, see Overview and Set up the Database Mirroring client. If you are migrating from the legacy service, see Migrate from the legacy mirroring service.- The registered application inside SuperOffice Operations Center (OC).
- The Mirroring Task, which is a background service in OC
- A web service that implements both the IMirrorClientService and IMirrorAdmin interfaces.
Implementation Overview
SuperOffice starts the process by sending the partner web service a security token that contains a tenant’s context identifier and timestamp. It’s up to the IMirroringClientService Authenticate method to validate the security token and respond with its ApplicationToken and timestamp. SuperOffice in turn validates the partner’s response to establish a two-way trust. There is no user or session concept in the Mirroring Client, so no session token is ever issued. The Mirroring Task will only proceed if it gets a valid response from the Client. The Mirroring Task sends the SuperOffice signed token with every call so that the Client can validate each call independently. OC handles the scheduling of the Mirroring Task, running it periodically for each customer and application instance. On each customer tenant, there are multiple tasks running in sequence. The mirroring task is scheduled to run every 20 minutes, but times may vary if there is another long-running customer task that is not yet finished. We also stop the task completely between 01.30 to 03:00 every night. For each cycle, the following operations are performed:- Authenticate with the registered service. SuperOffice sends a token that contains a signed context id + timestamp. The receiver validates it and then responds with its ApplicationToken + timestamp, signed with a private key. See the section System User Authentication in the Online Authentication in Detail article for the correct formatting. The NuGet package provided by SuperOffice includes methods to facilitate these functions.
-
For each table to be synchronized
- Check that change tracking is enabled for the table. If not, enable it
- Read the physical schema, and send it to the client
- The client responds with the Log Sequence Number (a 64-bit integer assigned by SQL Server) it has data for, for that table; and also updates its physical schema (including creating the table from scratch) as needed.
- Read the
<chunksize>oldest changes from the table. If change tracking was not installed previously, or the client did not have the table, all rows are considered changed - Transmit the changes to the client, each row includes its Log Sequence Number.
- The client writes the data to the mirror and returns the Log Sequence Number of the last successfully written row.
- Repeat 2.4 - 2.6 until no more changes are found
- After the last table has been synchronized, call the ReplicationCompleted method to indicate that mirroring is complete for this customer. The call can be used to generate indexes or perform other relevant tasks.