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>Clock Skew</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_lease.html" title="Master Leases" /> 12 <link rel="next" href="rep_partition.html" title="Network partitions" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Clock Skew</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="rep_lease.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��12.�� 23 Berkeley DB Replication 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="rep_partition.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="rep_clock_skew"></a>Clock Skew</h2> 35 </div> 36 </div> 37 </div> 38 <p>Since master leases take into account a timeout that is used across 39all sites in a replication group, leases must also take into account 40any known skew (or drift) between the clocks on different machines 41in the group. The guarantees provided by master leases take clock 42skew into account. Consider a replication group where a client's 43clock is running faster than the master's clock and the group has 44a lease timeout of 5 seconds. If clock skew is not taken into 45account, eventually, the client will believe that 5 seconds have 46passed faster than the master and that client may then grant its 47lease to another site. Meanwhile, the master site does not believe 485 seconds have passed because its clock is slower, and it believes 49it still holds a valid lease grant. For this reason, Berkeley DB compensates 50for clock skew.</p> 51 <p>The master of a group using leases must account for skew 52in case that site has the slowest clock in the group. This computation 53avoids the problem of a master site believing a lease grant is valid 54too long. Clients in a group must account for skew in case they 55have the fastest clock in the group. This computation avoids 56the problem of a client site expiring its grant too soon and 57potentially granting a lease to a different site. Berkeley DB uses 58a conservative computation and accounts for clock skew on both 59sides, yielding a double compensation.</p> 60 <p>The <a href="../api_reference/C/repclockskew.html" class="olink">DB_ENV->rep_set_clockskew()</a> method takes the values for both the fastest 61and slowest clocks in the entire replication group as parameters. 62The values passed in must be the same for all sites in the group. 63If the user knows the maximum clock drift of their sites, then those 64values can be expressed as a relative percentage. Or, if the user 65runs an experiment then the actual values can be used.</p> 66 <p>For example, suppose the user knows that there is a maximum drift 67rate of 2% among sites in the group. The user should pass in 68102 and 100 for the fast and slow clock values respectively. 69That is an unusually large value, so suppose, for example, the 70rate is 0.03% among sites in the group. The user should pass in 7110003 and 10000 for the fast and slow clock values. Those values 72can be used to express the level of precision the user needs.</p> 73 <p>An example of an experiment a user can run to help determine skew 74would be to write a program that started simultaneously on all 75sites in the group. Suppose, after 1 day (86400 seconds), one 76site shows 86400 seconds and the other site shows it ran faster 77and it indicates 86460 seconds has passed. 78The user can use 86460 and 86400 for their parameters for the 79fast and slow clock values.</p> 80 <p>Since Berkeley DB is using those fast and slow clock values to compute 81a ratio internally, if the user cannot detect or measure any 82clock skew, then the same value should be passed in for both 83parameters, such as 1 and 1.</p> 84 </div> 85 <div class="navfooter"> 86 <hr /> 87 <table width="100%" summary="Navigation footer"> 88 <tr> 89 <td width="40%" align="left"><a accesskey="p" href="rep_lease.html">Prev</a>��</td> 90 <td width="20%" align="center"> 91 <a accesskey="u" href="rep.html">Up</a> 92 </td> 93 <td width="40%" align="right">��<a accesskey="n" href="rep_partition.html">Next</a></td> 94 </tr> 95 <tr> 96 <td width="40%" align="left" valign="top">Master Leases��</td> 97 <td width="20%" align="center"> 98 <a accesskey="h" href="index.html">Home</a> 99 </td> 100 <td width="40%" align="right" valign="top">��Network partitions</td> 101 </tr> 102 </table> 103 </div> 104 </body> 105</html> 106