| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Choosing a Replication Manager Ack Policy</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="rep.html" title="Chapter 12. Berkeley DB Replication" /> |
| 11 | <link rel="prev" href="rep_replicate.html" title="Running Replication using the db_replicate Utility" /> |
| 12 | <link rel="next" href="rep_elect.html" title="Elections" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Choosing a Replication Manager Ack Policy</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="rep_replicate.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 12. |
| 26 | Berkeley DB Replication |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="rep_elect.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="rep_mgr_ack"></a>Choosing a Replication Manager Ack Policy</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>Replication Manager allows the user to choose from a variety of |
| 42 | acknowledgement policies. There are two characteristics that should |
| 43 | be considered when choosing the policy: consistency and durability. |
| 44 | Consistency means making sure some number of clients have applied |
| 45 | all available master transactions. Durability, in this context, |
| 46 | means only indicating success only if enough clients have |
| 47 | applied a transaction. The issue of how many is enough depends |
| 48 | on the application's requirements and varies per acknowledgement policy. |
| 49 | For example, <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_QUORUM" class="olink">DB_REPMGR_ACKS_QUORUM</a> means the data will survive |
| 50 | a change in master or a network partition. |
| 51 | In most cases, the number of sites for consistency is |
| 52 | equal to the number of sites for durability. Replication Manager |
| 53 | uses the consistency value to decide whether or not to wait for |
| 54 | acknowledgements. Replication manager uses the durability value |
| 55 | to decide either the transaction was successfully processed or that |
| 56 | a <a href="../api_reference/C/envevent_notify.html#event_notify_DB_EVENT_REP_PERM_FAILED" class="olink">DB_EVENT_REP_PERM_FAILED</a> event should be generated.</p> |
| 57 | <p>Replication Manager also strives to give the application the |
| 58 | answer and return to the application as quickly as possible. Therefore, |
| 59 | if it knows that the number of sites connected is insufficient to meet |
| 60 | the consistency value, then it does not wait for any acknowledgements |
| 61 | and if it knows that the durability value cannot be met, it returns |
| 62 | <a href="../api_reference/C/envevent_notify.html#event_notify_DB_EVENT_REP_PERM_FAILED" class="olink">DB_EVENT_REP_PERM_FAILED</a> immediately to the user.</p> |
| 63 | <p>With one exception, discussed below, all acknowledgement policies combine |
| 64 | the consistency and durability values. For most policies the primary |
| 65 | purpose is the durability of the data. For example, the <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_QUORUM" class="olink">DB_REPMGR_ACKS_QUORUM</a> |
| 66 | policy ensures that, if successful, the transaction's data is safe in |
| 67 | the event of a network partition so that a majority of the sites in |
| 68 | the group have the data. The <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_NONE" class="olink">DB_REPMGR_ACKS_NONE</a> policy does not |
| 69 | consider either consistency or durability, and it is very |
| 70 | fast because it does not wait for any acknowledgements and it does not |
| 71 | ever trigger the <a href="../api_reference/C/envevent_notify.html#event_notify_DB_EVENT_REP_PERM_FAILED" class="olink">DB_EVENT_REP_PERM_FAILED</a> event. Other policies, |
| 72 | <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL" class="olink">DB_REPMGR_ACKS_ALL</a> and <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL_PEERS" class="olink">DB_REPMGR_ACKS_ALL_PEERS</a>, have a primary purpose of |
| 73 | consistency. These two policies wait for acknowledgements from all |
| 74 | (or all electable) sites in the group.</p> |
| 75 | <p>In the face of failure, however, the <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL" class="olink">DB_REPMGR_ACKS_ALL</a> and |
| 76 | <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL_PEERS" class="olink">DB_REPMGR_ACKS_ALL_PEERS</a> policies can result |
| 77 | in a surprising lack of consistency due to the fact that Replication Manager |
| 78 | strives to give the answer back to the application as fast as it can. |
| 79 | So, for example, with <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL" class="olink">DB_REPMGR_ACKS_ALL</a>, and one site down, Replication |
| 80 | Manager knows that disconnected site can never acknowledge, so it |
| 81 | immediately triggers <a href="../api_reference/C/envevent_notify.html#event_notify_DB_EVENT_REP_PERM_FAILED" class="olink">DB_EVENT_REP_PERM_FAILED</a>. An unfortunate side |
| 82 | effect of this policy is that existing, running sites may fall further and |
| 83 | further behind the master if the master site is sending a fast, busy |
| 84 | stream of transactions and never waiting for any site to send an |
| 85 | acknowledgement. The master does not wait because the consistency |
| 86 | value cannot be met, and it does trigger the <a href="../api_reference/C/envevent_notify.html#event_notify_DB_EVENT_REP_PERM_FAILED" class="olink">DB_EVENT_REP_PERM_FAILED</a> |
| 87 | event because the durability value cannot be met, but those |
| 88 | actions now affect the consistency of the other running sites.</p> |
| 89 | <p>In order to counteract this unfortunate side effect, |
| 90 | the <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL_AVAILABLE" class="olink">DB_REPMGR_ACKS_ALL_AVAILABLE</a> acknowledgement policy focuses on the |
| 91 | consistency aspect, but also considers durability. This policy |
| 92 | uses all sites for consistency, |
| 93 | and a quorum of sites for its decision about durability. As long |
| 94 | as there is a non-zero number of client replicas to send to, the |
| 95 | master will wait for all available sites to acknowledge the |
| 96 | transaction. As long as any client site is connected, this policy |
| 97 | will prevent the master from racing ahead if one or more sites is down. |
| 98 | On the master, this policy will then consider the transaction durable if |
| 99 | the number of acknowledgements meets quorum for the group.</p> |
| 100 | <p>The following acknowledgement policies determine durability |
| 101 | using acknowledgements from electable peers only: <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_QUORUM" class="olink">DB_REPMGR_ACKS_QUORUM</a>, |
| 102 | <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ONE_PEER" class="olink">DB_REPMGR_ACKS_ONE_PEER</a>, <a href="../api_reference/C/repmgrset_ack_policy.html#ackspolicy_DB_REPMGR_ACKS_ALL_PEERS" class="olink">DB_REPMGR_ACKS_ALL_PEERS</a>. An electable |
| 103 | peer is a site where the priority value is greater than zero. In |
| 104 | replication groups using these policies, an unelectable site does not |
| 105 | send acknowledgements and cannot contribute to transaction durability.</p> |
| 106 | </div> |
| 107 | <div class="navfooter"> |
| 108 | <hr /> |
| 109 | <table width="100%" summary="Navigation footer"> |
| 110 | <tr> |
| 111 | <td width="40%" align="left"><a accesskey="p" href="rep_replicate.html">Prev</a> </td> |
| 112 | <td width="20%" align="center"> |
| 113 | <a accesskey="u" href="rep.html">Up</a> |
| 114 | </td> |
| 115 | <td width="40%" align="right"> <a accesskey="n" href="rep_elect.html">Next</a></td> |
| 116 | </tr> |
| 117 | <tr> |
| 118 | <td width="40%" align="left" valign="top">Running Replication using the db_replicate Utility </td> |
| 119 | <td width="20%" align="center"> |
| 120 | <a accesskey="h" href="index.html">Home</a> |
| 121 | </td> |
| 122 | <td width="40%" align="right" valign="top"> Elections</td> |
| 123 | </tr> |
| 124 | </table> |
| 125 | </div> |
| 126 | </body> |
| 127 | </html> |