hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181408 - in /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase: regionserver/RSZookeeperUpdater.java zookeeper/ZooKeeperWrapper.java
Date Tue, 11 Oct 2011 02:05:59 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:05:58 2011
New Revision: 1181408

URL: http://svn.apache.org/viewvc?rev=1181408&view=rev
Log:
Stale reads from ZK can break the atomic CAS operations

Summary:
Adds a sync(path) method to ZKWrapper and calls it from RSZKUpdater before we
do the initial read.

Test Plan:
Need to run test suite.  Currently testing this on the new master.

DiffCamp Revision: 172365
Reviewed By: kranganathan
CC: kranganathan, hbase@lists
Revert Plan:
OK

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java?rev=1181408&r1=1181407&r2=1181408&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/RSZookeeperUpdater.java
Tue Oct 11 02:05:58 2011
@@ -92,6 +92,7 @@ public class RSZookeeperUpdater {
    * @param updatePeriodically - if true, periodically updates the state in ZK
    */
   public void startRegionOpenEvent(HMsg hmsg, boolean updatePeriodically) throws IOException
{
+    zkWrapper.sync(regionZNode);
     Stat stat = new Stat();
     byte[] data = zkWrapper.readZNode(regionZNode, stat);
     // if there is no ZNode for this region, something is wrong

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java?rev=1181408&r1=1181407&r2=1181408&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
Tue Oct 11 02:05:58 2011
@@ -425,6 +425,22 @@ public class ZooKeeperWrapper implements
   }
 
   /**
+   * Forces a synchronization of this ZooKeeper client connection.
+   * <p>
+   * Executing this method before running other methods will ensure that the
+   * subsequent operations are up-to-date and consistent as of the time that
+   * the sync is complete.
+   * <p>
+   * This is used for compareAndSwap type operations where we need to read the
+   * data of an existing node and delete or transition that node, utilizing the
+   * previously read version and data.  We want to ensure that the version read
+   * is up-to-date from when we begin the operation.
+   */
+  public void sync(String path) {
+    this.zooKeeper.sync(path, null, null);
+  }
+
+  /**
    * Check if the specified znode exists.  Set a watch if boolean is true,
    * whether or not the node exists.
    * @param znode



Mime
View raw message