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 394E3200BEB for ; Tue, 13 Dec 2016 23:29:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 36145160B07; Tue, 13 Dec 2016 22:29:00 +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 81221160B23 for ; Tue, 13 Dec 2016 23:28:59 +0100 (CET) Received: (qmail 30695 invoked by uid 500); 13 Dec 2016 22:28:58 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 30680 invoked by uid 99); 13 Dec 2016 22:28:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2016 22:28:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 740D62C03DF for ; Tue, 13 Dec 2016 22:28:58 +0000 (UTC) Date: Tue, 13 Dec 2016 22:28:58 +0000 (UTC) From: "Andrew Purtell (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-17300) Concurrently calling checkAndPut with expected value as null returns true unexpectedly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 13 Dec 2016 22:29:00 -0000 [ https://issues.apache.org/jira/browse/HBASE-17300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15746476#comment-15746476 ] Andrew Purtell commented on HBASE-17300: ---------------------------------------- The client makes it appear its synchronous so this is not incorrect. I'm just letting you know on the master it is not. > Concurrently calling checkAndPut with expected value as null returns true unexpectedly > -------------------------------------------------------------------------------------- > > Key: HBASE-17300 > URL: https://issues.apache.org/jira/browse/HBASE-17300 > Project: HBase > Issue Type: Bug > Affects Versions: 0.98.23, 1.2.4 > Reporter: Samarth Jain > Attachments: HBASE-17300.patch > > > Attached is the test case. I have added some comments so hopefully the test makes sense. It actually is causing test failures on the Phoenix branches. > The test fails consistently using HBase-0.98.23. It exhibits flappy behavior with the 1.2 branch (failed twice in 5 tries). > {code} > @Test > public void testNullCheckAndPut() throws Exception { > try (HBaseAdmin admin = TEST_UTIL.getHBaseAdmin()) { > Callable c1 = new CheckAndPutCallable(); > Callable c2 = new CheckAndPutCallable(); > ExecutorService e = Executors.newFixedThreadPool(5); > Future f1 = e.submit(c1); > Future f2 = e.submit(c2); > assertTrue(f1.get() || f2.get()); > assertFalse(f1.get() && f2.get()); > } > } > } > > > private static final class CheckAndPutCallable implements Callable { > @Override > public Boolean call() throws Exception { > byte[] rowToLock = "ROW".getBytes(); > byte[] colFamily = "COLUMN_FAMILY".getBytes(); > byte[] column = "COLUMN".getBytes(); > byte[] newValue = "NEW_VALUE".getBytes(); > byte[] oldValue = "OLD_VALUE".getBytes(); > byte[] tableName = "table".getBytes(); > boolean acquired = false; > try (HBaseAdmin admin = TEST_UTIL.getHBaseAdmin()) { > HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName)); > HColumnDescriptor columnDesc = new HColumnDescriptor(colFamily); > columnDesc.setTimeToLive(600); > tableDesc.addFamily(columnDesc); > try { > admin.createTable(tableDesc); > } catch (TableExistsException e) { > // ignore > } > try (HTableInterface table = admin.getConnection().getTable(tableName)) { > Put put = new Put(rowToLock); > put.add(colFamily, column, oldValue); // add a row with column set to oldValue > table.put(put); > put = new Put(rowToLock); > put.add(colFamily, column, newValue); > // only one of the threads should be able to get return value of true for the expected value of oldValue > acquired = table.checkAndPut(rowToLock, colFamily, column, oldValue, put); > if (!acquired) { > // if a thread didn't get true before, then it shouldn't get true this time either > // because the column DOES exist > acquired = table.checkAndPut(rowToLock, colFamily, column, null, put); > } > } > } > } > return acquired; > } > } > {code} > cc [~apurtell], [~jamestaylor], [~lhofhansl]. -- This message was sent by Atlassian JIRA (v6.3.4#6332)