Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D59A910CDF for ; Fri, 19 Dec 2014 20:03:22 +0000 (UTC) Received: (qmail 17071 invoked by uid 500); 19 Dec 2014 20:03:20 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 16989 invoked by uid 500); 19 Dec 2014 20:03:20 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 16864 invoked by uid 99); 19 Dec 2014 20:03:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Dec 2014 20:03:20 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sduskis@gmail.com designates 209.85.217.171 as permitted sender) Received: from [209.85.217.171] (HELO mail-lb0-f171.google.com) (209.85.217.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Dec 2014 20:03:15 +0000 Received: by mail-lb0-f171.google.com with SMTP id w7so1410482lbi.30 for ; Fri, 19 Dec 2014 12:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Hhsy5ByXZGZIXiPax3K3u8SRS2QZ62KdDR3ru2OwhFY=; b=kBj/0xc1lkrczDAjdApq+irF/vd/kIGUU5jC2sFEC21GEN3k0GzfJ6YI5W+FFaGHKV v2GduDXXrvJpNG9+T5h8UYIA8nyHqcuy5FtAgVBw45u5Y+biC8NEfM9cnHw3DKems2Gk LOZJOYcAlLD2TweNzo6Sp5ZbO/4VZp8fj3pa9cOM1EqROJZefiTe4LCbO5Q2Jh7bMyO+ 8/sf4rCkPPAUWWAco+hUHEUoMp/4mkq8A8goZiv9qZgBSDoFtFqBWpJQIxzdPunE5qeM JAhc1mhKuW726UiTJECtY9TJkCRuzVr/6z+NmlOY5XsqhCwvTY6P3vUybunge8W1S+Gk QsxA== MIME-Version: 1.0 X-Received: by 10.152.121.100 with SMTP id lj4mr9486153lab.58.1419019374487; Fri, 19 Dec 2014 12:02:54 -0800 (PST) Received: by 10.112.93.76 with HTTP; Fri, 19 Dec 2014 12:02:54 -0800 (PST) In-Reply-To: References: Date: Fri, 19 Dec 2014 15:02:54 -0500 Message-ID: Subject: Re: Efficient use of buffered writes in a post-HTablePool world? From: Solomon Duskis To: user@hbase.apache.org Cc: lars hofhansl , =?UTF-8?Q?Enis_S=C3=B6ztutar?= Content-Type: multipart/alternative; boundary=089e01177631beefc5050a97313c X-Virus-Checked: Checked by ClamAV on apache.org --089e01177631beefc5050a97313c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Is this critical to sort out before 1.0, or is fixing this a post-1.0 enhancement? -Solomon On Fri, Dec 19, 2014 at 2:19 PM, Andrew Purtell wrote= : > > I don't like the dropped writes either. Just pointing out what we have no= w. > There is a gap no doubt. > > On Fri, Dec 19, 2014 at 11:16 AM, Nick Dimiduk > wrote: > > > > Thanks for the reminder about the Multiplexer, Andrew. It sort-of solve= s > > this problem, but think it's semantics of dropping writes are not > desirable > > in the general case. Further, my understanding was that the new > connection > > implementation is designed to handle this kind of use-case (hence cc'in= g > > Lars). > > > > On Fri, Dec 19, 2014 at 11:02 AM, Andrew Purtell > > wrote: > > > > > > Aaron: Please post a copy of that feedback on the JIRA, pretty sure w= e > > will > > > be having an improvement discussion there. > > > > > > On Fri, Dec 19, 2014 at 10:58 AM, Aaron Beppu > > > wrote: > > > > > > > > Nick : Thanks, I've created an issue [1]. > > > > > > > > Pradeep : Yes, I have considered using that. However for the moment= , > > > we've > > > > set it out of scope, since our migration from 0.94 -> 0.98 is > already a > > > bit > > > > complicated, and we hoped to separate isolate these changes by not > > moving > > > > to the async client until after the current migration is complete. > > > > > > > > Andrew : HTableMultiplexer does seem like it would solve our buffer= ed > > > write > > > > problem, albeit in an awkward way -- thanks! It kind of seems like > > HTable > > > > should then (if autoFlush =3D=3D false) send writes to the multiple= xer, > > > rather > > > > than setting it in its own, short-lived writeBuffer. If nothing els= e, > > > it's > > > > still super confusing that HTableInterface exposes setAutoFlush() a= nd > > > > setWriteBufferSize(), given that the writeBuffer won't meaningfully > > > buffer > > > > anything if all tables are short-lived. > > > > > > > > [1] https://issues.apache.org/jira/browse/HBASE-12728 > > > > > > > > On Fri, Dec 19, 2014 at 10:31 AM, Andrew Purtell < > apurtell@apache.org> > > > > wrote: > > > > > > > > > > I believe HTableMultiplexer[1] is meant to stand in for HTablePoo= l > > for > > > > > buffered writing. FWIW, I've not used it. > > > > > > > > > > 1: > > > > > > > > > > > > > > > > > > > > https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTableMul= tiplexer.html > > > > > > > > > > > > > > > On Fri, Dec 19, 2014 at 9:00 AM, Nick Dimiduk > > > > > wrote: > > > > > > > > > > > > Hi Aaron, > > > > > > > > > > > > Your analysis is spot on and I do not believe this is by design= . > I > > > see > > > > > the > > > > > > write buffer is owned by the table, while I would have expected > > there > > > > to > > > > > be > > > > > > a buffer per table all managed by the connection. I suggest you > > > raise a > > > > > > blocker ticket vs the 1.0.0 release that's just around the corn= er > > to > > > > give > > > > > > this the attention it needs. Let me know if you're not into > JIRA, I > > > can > > > > > > raise one on your behalf. > > > > > > > > > > > > cc Lars, Enis. > > > > > > > > > > > > Nice work Aaron. > > > > > > -n > > > > > > > > > > > > On Wed, Dec 17, 2014 at 6:44 PM, Aaron Beppu < > > abeppu@siftscience.com > > > > > > > > > > wrote: > > > > > > > > > > > > > > Hi All, > > > > > > > > > > > > > > TLDR; in the absence of HTablePool, if HTable instances are > > > > > short-lived, > > > > > > > how should clients use buffered writes? > > > > > > > > > > > > > > I=E2=80=99m working on migrating a codebase from using 0.94.6= (CDH4.4) > to > > > > > 0.98.6 > > > > > > > (CDH5.2). One issue I=E2=80=99m confused by is how to effecti= vely use > > > > buffered > > > > > > > writes now that HTablePool has been deprecated[1]. > > > > > > > > > > > > > > In our 0.94 code, a pathway could get a table from the pool, > > > > configure > > > > > it > > > > > > > with table.setAutoFlush(false); and write Puts to it. Those > > writes > > > > > would > > > > > > > then go to the table instance=E2=80=99s writeBuffer, and thos= e writes > > would > > > > > only > > > > > > be > > > > > > > flushed when the buffer was full, or when we were ready to > close > > > out > > > > > the > > > > > > > pool. We were intentionally choosing to have fewer, larger > writes > > > > from > > > > > > the > > > > > > > client to the cluster, and we knew we were giving up a degree > of > > > > safety > > > > > > in > > > > > > > exchange (i.e. if the client dies after it=E2=80=99s accepted= a write > but > > > > > before > > > > > > > the flush for that write occurs, the data is lost). This seem= s > to > > > be > > > > a > > > > > > > generally considered a reasonable choice (cf the HBase Book [= 2] > > SS > > > > > > 14.8.4) > > > > > > > > > > > > > > However in the 0.98 world, without HTablePool, the endorsed > > pattern > > > > [3] > > > > > > > seems to be to create a new HTable via table =3D > > > > > > > stashedHConnection.getTable(tableName, myExecutorService). > > However, > > > > > even > > > > > > if > > > > > > > we do table.setAutoFlush(false), because that table instance = is > > > > > > > short-lived, its buffer never gets full. We=E2=80=99ll create= a table > > > > instance, > > > > > > > write a put to it, try to close the table, and the close call > > will > > > > > > trigger > > > > > > > a (synchronous) flush. Thus, not having HTablePool seems like > it > > > > would > > > > > > > cause us to have many more small writes from the client to th= e > > > > cluster, > > > > > > and > > > > > > > basically wipe out the advantage of turning off autoflush. > > > > > > > > > > > > > > More concretely : > > > > > > > > > > > > > > // Given these two helpers ... > > > > > > > > > > > > > > private HTableInterface getAutoFlushTable(String tableName) > > throws > > > > > > > IOException { > > > > > > > // (autoflush is true by default) > > > > > > > return storedConnection.getTable(tableName, executorService= ); > > > > > > > } > > > > > > > > > > > > > > private HTableInterface getBufferedTable(String tableName) > throws > > > > > > > IOException { > > > > > > > HTableInterface table =3D getAutoFlushTable(tableName); > > > > > > > table.setAutoFlush(false); > > > > > > > return table; > > > > > > > } > > > > > > > > > > > > > > // it's my contention that these two methods would behave > almost > > > > > > > identically, > > > > > > > // except the first will hit a synchronous flush during the p= ut > > > call, > > > > > > > and the second will > > > > > > > // flush during the (hidden) close call on table. > > > > > > > > > > > > > > private void writeAutoFlushed(Put somePut) throws IOException= { > > > > > > > try (HTableInterface table =3D getAutoFlushTable(tableName)= ) { > > > > > > > table.put(somePut); // will do synchronous flush > > > > > > > } > > > > > > > } > > > > > > > > > > > > > > private void writeBuffered(Put somePut) throws IOException { > > > > > > > try (HTableInterface table =3D getBufferedTable(tableName))= { > > > > > > > table.put(somePut); > > > > > > > } // auto-close will trigger synchronous flush > > > > > > > } > > > > > > > > > > > > > > It seems like the only way to avoid this is to have long-live= d > > > HTable > > > > > > > instances, which get reused for multiple writes. However, sin= ce > > the > > > > > > actual > > > > > > > writes are driven from highly concurrent code, and since HTab= le > > is > > > > not > > > > > > > threadsafe, this would involve having a number of HTable > > instances, > > > > > and a > > > > > > > control mechanism for leasing them out to individual threads > > > safely. > > > > > > Except > > > > > > > at this point it seems like we will have recreated HTablePool= , > > > which > > > > > > > suggests that we=E2=80=99re doing something deeply wrong. > > > > > > > > > > > > > > What am I missing here? Since the HTableInterface.setAutoFlus= h > > > method > > > > > > still > > > > > > > exists, it must be anticipated that users will still want to > > buffer > > > > > > writes. > > > > > > > What=E2=80=99s the recommended way to actually buffer a meani= ngful > number > > > of > > > > > > > writes, from a multithreaded context, that doesn=E2=80=99t ju= st amount > to > > > > > > creating > > > > > > > a table pool? > > > > > > > > > > > > > > Thanks in advance, > > > > > > > Aaron > > > > > > > > > > > > > > [1] https://issues.apache.org/jira/browse/HBASE-6580 > > > > > > > [2] http://hbase.apache.org/book/perf.writing.html > > > > > > > [3] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://issues.apache.org/jira/browse/HBASE-6580?focusedCommentId=3D13501= 302&page=3Dcom.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel= #comment-13501302 > > > > > > > =E2=80=8B > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Best regards, > > > > > > > > > > - Andy > > > > > > > > > > Problems worthy of attack prove their worth by hitting back. - Pi= et > > > Hein > > > > > (via Tom White) > > > > > > > > > > > > > > > > > > -- > > > Best regards, > > > > > > - Andy > > > > > > Problems worthy of attack prove their worth by hitting back. - Piet > Hein > > > (via Tom White) > > > > > > > > -- > Best regards, > > - Andy > > Problems worthy of attack prove their worth by hitting back. - Piet Hein > (via Tom White) > --089e01177631beefc5050a97313c--