Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 3843D9A7B6E for ; Fri, 18 May 2012 08:34:42 -0300 (ADT) Received: from auth-smtp.nebula.fi ([217.30.180.105]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SVLSD-0006HB-0T for pgsql-jdbc@postgresql.org; Fri, 18 May 2012 11:34:42 +0000 Received: from quadvadis.localdomain (gw.nitor.fi [83.145.228.24]) (authenticated bits=0) by auth-smtp.nebula.fi (8.13.8/8.13.4) with ESMTP id q4IBYDum009062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 May 2012 14:34:14 +0300 Message-ID: <4FB633B4.70700@nitorcreations.com> Date: Fri, 18 May 2012 14:34:12 +0300 From: Mikko Tiihonen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Dave Cramer CC: Heikki Linnakangas , pgsql-jdbc@postgresql.org Subject: Re: Connection-fail-over References: <4FB52EBB.4060309@nitorcreations.com> <4FB5341B.8080206@enterprisedb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201205/60 X-Sequence-Number: 22960 On 05/17/2012 08:36 PM, Dave Cramer wrote: > On Thu, May 17, 2012 at 1:23 PM, Heikki Linnakangas > wrote: >> On 17.05.2012 20:00, Mikko Tiihonen wrote: >>> >>> Hi, >>> >>> I have been thinking of adding connection fail-over support to the jdbc >>> driver. What this means is that there would be a way to specify more >>> than host:port pair to connect to. This will become handy with >>> high-availability installations. >>> >>> Currently the limitation of hostname means that there has to be a >>> virtual ip address that is moved with the active backend, which is a >>> complex solution that can break. >>> >>> If we have list of hostname:port pairs we just have to make sure that >>> only the master database allows connections from the jdbc clients. >> >> >> I'd suggest doing this as a generic wrapper or proxy that would work with >> any JDBC driver, not just PostgreSQL's. Maybe there is such a thing out >> there already? I believe many application servers at least can do that, and >> then there's http://ha-jdbc.sourceforge.net/, which I think can do that too. >> > > I would agree with Heikki here that it makes more sense to have a > wrapper. I noticed that ha-jdbc has an lpgl license. How important is > it to have a bsd like license ? I did some googling and found out that * all of the 'competitors' have decided to build failover support into their jdbc drivers * big JavaEE servers have connection pool configurations that support failover * none of common the open source connection pools or web servers support connection failover Jdbc drivers that support connection failover: - mysql: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html - oracle: http://docs.oracle.com/cd/B28359_01/java.111/e10788/rac.htm - mssql: http://msdn.microsoft.com/en-us/library/aa342332%28v=sql.90%29.aspx - db2: http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.apdv.java.doc%2Fdoc%2Fcjvclrrt.htm Of the normal jdbc connection pools - c3p0: no support for failovers - dbcp: no support for failovers - bonecp: no support for failovers - tomcat: no support for failovers Application servers: - Weblogic: has MultiPools that support failover - Websphere: has Automatic Client Reroute - JBoss: has failover support - Glassfish: I could not find any built-in support for failover About HA-JDBC: Yes, looking at the documentation it can be configured for the simple connection failover use case, but the complexity is 21k lines of Java code which it uses to wrap the whole JDBC API. The latests discussions on the site were about deadlocks. Now that postgresql 9.x has nice built-in replication, the need for simple setup for client applications will become more important. And I believe that with less than 50 lines of code we can have a simple solution that works in most setups and allows the developer to choose any of the common java connection pools. Thus, I believe that it would be useful to have simple failover support in the jdbc driver. -Mikko