Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 96071200D27 for ; Wed, 20 Sep 2017 00:06:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 947601609DD; Tue, 19 Sep 2017 22:06:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D95991609E0 for ; Wed, 20 Sep 2017 00:06:22 +0200 (CEST) Received: (qmail 74197 invoked by uid 500); 19 Sep 2017 22:06:22 -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 74181 invoked by uid 99); 19 Sep 2017 22:06:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2017 22:06:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D389DF5762; Tue, 19 Sep 2017 22:06:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: apurtell@apache.org To: commits@hbase.apache.org Date: Tue, 19 Sep 2017 22:06:22 -0000 Message-Id: In-Reply-To: <580623cba7f64534960f5f9ecda96fb5@git.apache.org> References: <580623cba7f64534960f5f9ecda96fb5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] hbase git commit: HBASE-18796 Admin#isTableAvailable returns incorrect result before daughter regions are opened archived-at: Tue, 19 Sep 2017 22:06:23 -0000 HBASE-18796 Admin#isTableAvailable returns incorrect result before daughter regions are opened Signed-off-by: Andrew Purtell Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/29a3ff30 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/29a3ff30 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/29a3ff30 Branch: refs/heads/master Commit: 29a3ff303799299ce42b57e85b2a2ac575dab474 Parents: a29ea36 Author: Abhishek Singh Chouhan Authored: Mon Sep 18 15:02:11 2017 +0530 Committer: Andrew Purtell Committed: Tue Sep 19 15:06:15 2017 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hbase/MetaTableAccessor.java | 13 ++++++- .../hadoop/hbase/TestMetaTableAccessor.java | 41 ++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/29a3ff30/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java index 1b81359..47fffa2 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java @@ -1724,8 +1724,8 @@ public class MetaTableAccessor { Put putA = makePutFromRegionInfo(splitA); Put putB = makePutFromRegionInfo(splitB); - addLocation(putA, sn, 1, -1, splitA.getReplicaId()); //new regions, openSeqNum = 1 is fine. - addLocation(putB, sn, 1, -1, splitB.getReplicaId()); + addSequenceNum(putA, 1, -1, splitA.getReplicaId()); //new regions, openSeqNum = 1 is fine. + addSequenceNum(putB, 1, -1, splitB.getReplicaId()); // Add empty locations for region replicas of daughters so that number of replicas can be // cached whenever the primary region is looked up from meta @@ -2100,6 +2100,15 @@ public class MetaTableAccessor { return p.getClass().getSimpleName() + p.toJSON(); } + public static Put addSequenceNum(final Put p, long openSeqNum, long time, int replicaId) { + if (time <= 0) { + time = EnvironmentEdgeManager.currentTime(); + } + p.addImmutable(HConstants.CATALOG_FAMILY, getSeqNumColumn(replicaId), time, + Bytes.toBytes(openSeqNum)); + return p; + } + /** * Get replication position for a peer in a region. * @param connection connection we're using http://git-wip-us.apache.org/repos/asf/hbase/blob/29a3ff30/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java index 6e9454f..a0cd236 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java @@ -699,5 +699,46 @@ public class TestMetaTableAccessor { assertTrue(prevCalls < scheduler.numPriorityCalls); } } + + @Test + public void testEmptyMetaDaughterLocationDuringSplit() throws IOException { + long regionId = System.currentTimeMillis(); + ServerName serverName0 = ServerName.valueOf("foo", 60010, random.nextLong()); + HRegionInfo parent = new HRegionInfo(TableName.valueOf("table_foo"), HConstants.EMPTY_START_ROW, + HConstants.EMPTY_END_ROW, false, regionId, 0); + HRegionInfo splitA = new HRegionInfo(TableName.valueOf("table_foo"), HConstants.EMPTY_START_ROW, + Bytes.toBytes("a"), false, regionId + 1, 0); + HRegionInfo splitB = new HRegionInfo(TableName.valueOf("table_foo"), Bytes.toBytes("a"), + HConstants.EMPTY_END_ROW, false, regionId + 1, 0); + + Table meta = MetaTableAccessor.getMetaHTable(connection); + try { + List regionInfos = Lists.newArrayList(parent); + MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3); + + MetaTableAccessor.splitRegion(connection, parent, splitA, splitB, serverName0, 3, false); + Get get1 = new Get(splitA.getRegionName()); + Result resultA = meta.get(get1); + Cell serverCellA = resultA.getColumnLatestCell(HConstants.CATALOG_FAMILY, + MetaTableAccessor.getServerColumn(splitA.getReplicaId())); + Cell startCodeCellA = resultA.getColumnLatestCell(HConstants.CATALOG_FAMILY, + MetaTableAccessor.getStartCodeColumn(splitA.getReplicaId())); + assertNull(serverCellA); + assertNull(startCodeCellA); + + Get get2 = new Get(splitA.getRegionName()); + Result resultB = meta.get(get2); + Cell serverCellB = resultB.getColumnLatestCell(HConstants.CATALOG_FAMILY, + MetaTableAccessor.getServerColumn(splitB.getReplicaId())); + Cell startCodeCellB = resultB.getColumnLatestCell(HConstants.CATALOG_FAMILY, + MetaTableAccessor.getStartCodeColumn(splitB.getReplicaId())); + assertNull(serverCellB); + assertNull(startCodeCellB); + } finally { + if (meta != null) { + meta.close(); + } + } + } }