Return-Path: Delivered-To: apmail-hadoop-hbase-dev-archive@locus.apache.org Received: (qmail 11374 invoked from network); 12 Aug 2008 18:50:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Aug 2008 18:50:07 -0000 Received: (qmail 94529 invoked by uid 500); 12 Aug 2008 18:50:05 -0000 Delivered-To: apmail-hadoop-hbase-dev-archive@hadoop.apache.org Received: (qmail 94496 invoked by uid 500); 12 Aug 2008 18:50:05 -0000 Mailing-List: contact hbase-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-dev@hadoop.apache.org Received: (qmail 94455 invoked by uid 99); 12 Aug 2008 18:50:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 11:50:05 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 18:49:16 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7B3BA234C1AF for ; Tue, 12 Aug 2008 11:49:44 -0700 (PDT) Message-ID: <2027471883.1218566984503.JavaMail.jira@brutus> Date: Tue, 12 Aug 2008 11:49:44 -0700 (PDT) From: "Jonathan Gray (JIRA)" To: hbase-dev@hadoop.apache.org Subject: [jira] Commented: (HBASE-798) Provide Client API to explicitly lock and unlock rows In-Reply-To: <1531456165.1217997044438.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HBASE-798?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621929#action_12621929 ] Jonathan Gray commented on HBASE-798: ------------------------------------- Thanks for review Jim! 1) Agreed. 2) Okay. I was using the identical structure used to keep track of scanners: Map scanners = Collections.synchronizedMap(new HashMap()); Should that be changed as well? 3) Yes, I had it that way before but changed it for some reason. I think because I need to do a check at the end, but this checks the passed-in argument which is unchanged by the getLock function call. So you are correct, will change. 4) Yup. Will wait to hear back regarding synchronizedMap(new Hashmap()) versus ConcurrentHashMap() before posting new patch. Thanks again, Jim! > Provide Client API to explicitly lock and unlock rows > ----------------------------------------------------- > > Key: HBASE-798 > URL: https://issues.apache.org/jira/browse/HBASE-798 > Project: Hadoop HBase > Issue Type: New Feature > Components: client, ipc, regionserver > Reporter: Jonathan Gray > Assignee: Jonathan Gray > Priority: Minor > Fix For: 0.3.0 > > Attachments: hbase-798-v1.patch, hbase-798-v2.patch, hbase-798-v3.patch, hbase-798-v4.patch > > > We need to be able to perform a series of reads from and writes to a single row without any potential interference from other clients. > Unfortunately this is a bit involved because normal reads currently do not acquire row locks, so it requires adding additional get/getRow calls that obtain and release a row lock. > In addition, there will be two additional client calls, lockRow/unlockRow, which actually acquire and release the locks. Though each lock is associated with an HRegion, this will be tracked within the HRegionServer. When a lock is acquired from the client, it is handled much like a Scanner. We obtain the row lock from the HRegion, store the region name and lock identifier in a synchronized Map, and also obtain a lease to ensure that the lock will eventually be released even if the client dies. > This also required adding a RowLockListener (implements LeaseListener) private class in HRS to handle row lock lease expiration. > HRS.lockRow will return a long lockId (as openScanner does) that will be used in subsequent client calls to reuse this existing row lock. These calls will check that the lock is valid and perform the operations without any locking (wrappers around get*, new versions of batchUpdate, openScanner, etc). > This is going to really add some noise to the list of available HTable/client methods so I'm not sure if it's something people would want to commit into a normal release. Regardless this does provide some very convenient functionality that may be useful to others. > We are also looking into Clint Morgan's HBASE-669, but one major downside is that there is a significant amount of overhead involved. This row locking is already built in and this will only extend the API to allow clients to work with them directly. There is little to no overhead at all. The only (obvious) performance consideration is that this should only used where necessary as rows will not be locked and unlocked as quickly with round-trip client calls. In our design, we will have specific notes in our schema about which tables (or even which families or columns) must be accessed with row locks at all times and which do not. > This is my first attempt at adding any additional functionality, so comments, criticism, code reviews are encouraged. > I should have a patch up tomorrow. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.