|
|||||||||||
|
|
Handle Server Replication
(See also Interface Specification Handle System Protocol (ver 2.1) Specification , RFC 3652.)
(1) What is Replication?
Replication is the process by which changes in a primary handle site are communicated to one or more 'secondary' sites. A handle service has a single 'primary' site and zero or more 'secondary' sites that are simple mirrors of the primary. The number of servers in each site may vary. Clients are required to send all administrative messages (such as create/modify/delete-handle requests) only to a primary site. When a new secondary server is started, it requests all handles from the primary server(s). This a called "dump" because for some primary servers, the list can be very large and listing them takes time. Once the complete list is received, the secondary performs incremental replication. When a primary handle server receives a request to add, modify or delete a handle, it records an entry in a transaction log just prior to modifying the database. This transaction log can be viewed in the "txns" subdirectory of the primary handle server. There is a transaction log file for each calendar day, with one transaction per line. Each transaction consists of an encoded handle, the encoded type of change (add, delete, modify, home-prefix, unhome-prefix), a time-stamp and transaction ID. There is also an "index" file that contains the first time-stamp and transaction ID for each daily log. Secondary sites poll the primary (or another intermediate) site every n minutes (where n is generally between 1 and 5). The poll message includes the last transaction ID retrieved by the secondary, and the date of the last poll. If the last poll occurred before the replication source log begins, the response tells the secondary to skip incremental replication and re-copy the entire database from the source. Otherwise, the source returns the transactions that have occurred since the given transaction ID and includes the latest transaction ID. For transactions other than delete-handle, home-prefix and unhome-prefix, the current handle values are included with the transaction listing. Replication only works if handles are changed through an interaction with the primary handle server using the handle administrative protocol. That means that if you run a multi-server handle service, and your handle server is configured to use an SQL database as the back end, you will need to (1) take care of replication at the database level or (2) ensure that all changes are performed through the handle server.
(2) How is Replication Accomplished?
To do replication, a secondary needs to have and keep track of the following:
In the handle server, server replication is done in a separate thread. The replication daemon is a thread that retrieves handle transactions from the primary servers or some other source (depending on the server configuration). The replication daemon should only run on secondaries, not on primary servers. The replication daemon does the following:
(3) Details
Handle server replication communication is based on two request/response pairs. The secondary server sends out a request for new transactions or it sends a request for a dump of all the handles in the primary server. What follows is a description of the request and associated responses. (3.1) Retrieve Transactions Request:
This is the request used to retrieve any new transactions from a server. This request is used for server<->server (or replicator<->server) communication. The request needs to provide the following information to the server being queried:
The last transaction ID will allow the server being queried to determine which transactions need to be returned. The queried server will send every transaction that has a transaction ID greater than the last transaction ID and hashes to the requesting server. Knowing the last time the transactions were queried will allow the server being queried to determine if the entire set of handles needs to be "dumped" again. The following describes the body of the Retrieve Transactions Request handle protocol message as defined in Section 2 of RFC 3652. The Message Header of any Retrieve Transactions Request must set its <OpCode> to OC_RETRIEVE_TXN_LOG and its <ResponseCode> to 0.
where: <LastTransactionID> (3.2) Retrieve Transactions Response:
This is the response used to forward new transactions to a replicated site/server. This response is used for server<->server or (replicator<->server) communication. The response has two valid states. It will either be SENDING_TRANSACTIONS or it will indicate a NEED_TO_REDUMP all the handles for the servers being replicated. If NEED_TO_REDUMP is returned then the secondary site/server will request all the handles from all the servers in the primary site. If the Retrieve Transactions Response status is SENDING_TRANSACTIONS, the primary server wil stream all new transactions to the requesting secondary server. The following describes the body of the handle protocol message as defined in Section 2 of RFC 3652. The Message Header of any Retrieve Transactions Request must set its <OpCode> to RETRIEVE_TXN_LOG. A successful Retrieve Transactions Response must set its <ResponseCode> to RC_SUCCESS. This message is streamable.
where: <RequestDigest>
where: <RecordType> <TransactionDate> <EndTransmissionRecord> (3.3) Dump Handles Request:
This is the request used to retrieve all handles from a server. This request is used for server<->server (or replicator<->server) communication. The requesting server needs to specify which handles to send (filtered by how the handles are hashed)
The following describes the body of the Dump Handles Request handle protocol message as defined in Section 2 of RFC 3652: The Message Header of any Dump Handles Request must set its <OpCode> to <OC_DUMP_HANDLES> and its <ResponseCode> to 0.
where: <ReceiverHashType> (3.4) Dump Handles Response:
This is the response used to send all handles in the database to a replicated site/server. This response is used for server<->server (or replicator<->server) communication. This response is used by the primary server to send all of the handles that hash to the requestor beginning with the transaction ID specified in the Dump Handles Request. The message is signed using the normal handle response signature format as defined in Section 2.2.4 of RFC 3652. The following describes the body of the Dump Handles Response handle protocol message as defined in Section 2 of RFC 3652. The Message Header of any Dump Handles Response must set its <OpCode> to OC_RETRIEVE_TXN_LOG. A successful Dump Handles Response must set its <ResponseCode> to RC_SUCCESS. This message is streamable.
where: <RequestDigest> If a handle hashes to the requesting server, the following bytes are streamed: The data sent to the requestor for each record is defined as follows:
For Handle Records: <RecordType> For Prefix (Naming Authority) Records: <RecordType> <EndTransmissionRecord> <LastTxnId> (3.5) <OpCode> used for handle Server Replication:
Op_Code | Symbolic Name | Remark
--------|---------------------|-------------------------
1001 | OC_RETRIEVE_TXN_LOG | Retrieve Transaction Log
1002 | OC_DUMP_HANDLES | Dump Handles
(3.6) More Information on Transaction Types:
The Retrieve Transactions Response Message streams transactions to the secondary server. This section provides a little more detail on each of these transactions types.
Transaction Actions | Integer Value
--------------------------|--------------
ACTION_PLACEHOLDER | 0
ACTION_CREATE_HANDLE | 1
ACTION_DELETE_HANDLE | 2
ACTION_UPDATE_HANDLE | 3
ACTION_HOME_NA | 4
ACTION_UNHOME_NA | 5
ACTION_DELETE_ALL | 6
ACTION_PLACEHOLDER ACTION_CREATE_HANDLE ACTION_DELETE_HANDLE ACTION_UPDATE_HANDLE ACTION_HOME_NA ACTION_UNHOME_NA ACTION_DELETE_ALL (3.7) Additional Considerations:
The Dump Handles Request/Response and the ACTION_DELETE_ALL transaction should be used carefully. Setting up secondary servers such that they alert an administrator when a Dump Handles Request or ACTION_DELETE_ALL transaction is received, and requiring administrator confirmation of these actions, are recommended. (See also Interface Specification Handle System Protocol (ver 2.1) Specification , RFC 3652.) Updated 27 July 2007
Send inquiries to hdladmin@cnri.reston.va.us |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||