Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D4D56540 for ; Thu, 4 Aug 2011 23:10:51 +0000 (UTC) Received: (qmail 70948 invoked by uid 500); 4 Aug 2011 23:10:50 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 70806 invoked by uid 500); 4 Aug 2011 23:10:50 -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 70798 invoked by uid 99); 4 Aug 2011 23:10:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 23:10:49 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 23:10:48 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B5CE9A8967 for ; Thu, 4 Aug 2011 23:10:27 +0000 (UTC) Date: Thu, 4 Aug 2011 23:10:27 +0000 (UTC) From: "Gary Helmling (JIRA)" To: issues@hbase.apache.org Message-ID: <1024386030.9791.1312499427741.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1548933183.21946.1312148229541.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (HBASE-4150) Potentially too many connections may be opened if ThreadLocalPool or RoundRobinPool is used MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-4150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gary Helmling updated HBASE-4150: --------------------------------- Attachment: HBASE-4150_final.patch Committed this patch (HBASE-4150_final.patch) to trunk. This is based on 5140-2.patch, plus a fix for TestPoolMap to reflect the non-enforcement of limit with ThreadLocalPool. So this removes use of pool max size when using ThreadLocalPool. > Potentially too many connections may be opened if ThreadLocalPool or RoundRobinPool is used > ------------------------------------------------------------------------------------------- > > Key: HBASE-4150 > URL: https://issues.apache.org/jira/browse/HBASE-4150 > Project: HBase > Issue Type: Bug > Reporter: Ted Yu > Assignee: Gary Helmling > Fix For: 0.92.0 > > Attachments: 4150-1.txt, 4150.txt, 5140-2.txt, HBASE-4150_final.patch > > > See 'Problem with hbase.client.ipc.pool.type=threadlocal in trunk' discussion started by Lars George. > From Lars Hofhansl: > Looking at HBaseClient.getConnection(...) I see this: > {code} > synchronized (connections) { > connection = connections.get(remoteId); > if (connection == null) { > connection = new Connection(remoteId); > connections.put(remoteId, connection); > } > } > {code} > At the same time PoolMap.ThreadLocalPool.put is defined like this: > {code} > public R put(R resource) { > R previousResource = get(); > if (previousResource == null) { > ... > if (poolSize.intValue() >= maxSize) { > return null; > } > ... > } > {code} > So... If the ThreadLocalPool reaches its capacity it always returns null and hence all new threads will create a > new connection every time getConnection is called! > I have also verified with a test program that works fine as long as the number of client threads (which include > the threads in HTable's threadpool of course) is < poolsize. Once that is no longer the case the number of > connections "explodes" and the program dies with OOMEs (mostly because each Connection is associated with > yet another thread). > It's not clear what should happen, though. Maybe (1) the ThreadLocalPool should not have a limit, or maybe > (2) allocations past the pool size should throw an exception (i.e. there's a hard limit), or maybe (3) in that case > a single connection is returned for all threads while the pool it over its limit or (4) we start round robin with the other > connection in the other thread locals. > For #1 means that the number of client threads needs to be more carefully managed by the client app. > In this case it would also be somewhat pointless that Connection have their own threads, we just pass stuff > between threads. > #2 would work, but puts more logic in the client. > #3 would lead to hard to debug performance issues. > And #4 is messy :) > From Ted Yu: > For HBaseClient, at least the javadoc doesn't match: > {code} > * @param config configuration > * @return either a {@link PoolType#Reusable} or {@link PoolType#ThreadLocal} > */ > private static PoolType getPoolType(Configuration config) { > return PoolType.valueOf(config.get(HConstants.HBASE_CLIENT_IPC_POOL_TYPE), > PoolType.RoundRobin, PoolType.ThreadLocal); > {code} > I think for RoundRobinPool, we shouldn't allow maxSize to be Integer#MAX_VALUE. Otherwise connection explosion described by Lars may incur. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira