From: | Bill Schneider <bschneider(at)vecna(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: [pgsql-jdbc] Daily digest v1.861 (1 messages) |
Date: | 2003-02-28 14:10:36 |
Message-ID: | 008001c2df33$2aa27050$6601a8c0@complexity |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
There are generally two ways to fix this:
- rewrite the application to use a single connection, as you suggest. This
is the best solution. If you have to nest queries (i.e., running a query
while interating over the results of another) it's probably a sign that you
are doing something else wrong, like not taking advantage of database joins.
You'll fix your deadlocks and get better performance.
- use Java synchronization such that grabbing all three connections is an
atomic operation. This is not as good. You'll prevent deadlock, but
requests for this page will stall while other requests finish.
-- Bill
> Date: Thu, 27 Feb 2003 21:25:08 -0800 (PST)
> From: Anil Kumar <techbreeze(at)yahoo(dot)com>
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: Connection pool deadlock
> Message-ID: <20030228052508(dot)79222(dot)qmail(at)web13903(dot)mail(dot)yahoo(dot)com>
>
> Hi All,
>
> I'm facing a problem with connection pooling. I'm using the
> pg73jdbc3.jar
> with PG 7.2 on RH 7.3.
>
> This is a Web application running on Tomcat. To render one of its
> pages it
> requires three concurrent connections to the database. It requests
> one
> connection after another and return them in the reverse order (the
> last
> obtained connection is returned first and so on). This creates a
> dead-lock
> if multiple requests are coming for this particular page. For
> example if
> the pool size is 10 and if the application is getting 4
> simultaneous
> requests for this page I found that the connection allocation
> happens in
> the following way:
From | Date | Subject | |
---|---|---|---|
Next Message | Dirk Bromberg | 2003-02-28 16:38:29 | Connection Pool |
Previous Message | Dirk Bromberg | 2003-02-28 12:55:34 | ConnectionPool howto |