Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EFA1E7A70 for ; Tue, 11 Oct 2011 02:06:20 +0000 (UTC) Received: (qmail 43006 invoked by uid 500); 11 Oct 2011 02:06:20 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 42983 invoked by uid 500); 11 Oct 2011 02:06:20 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 42976 invoked by uid 99); 11 Oct 2011 02:06:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:06:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:06:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8C3052388A64 for ; Tue, 11 Oct 2011 02:05:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hbase.apache.org From: nspiegelberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011020559.8C3052388A64@eris.apache.org> 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. + *

+ * 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. + *

+ * 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