Обсуждение: DataSource suddenly drops all connections?

Поиск
Список
Период
Сортировка

DataSource suddenly drops all connections?

От
Holger Klawitter
Дата:
Hi there,

I've run into a strange problem with Tomcat (4.1.12; JDK 1.4.1_01; Linux
2.4.19). My webappliaction connects to a postgres database (7.3) via
javax.sql.DataSource (I am using the jdbc driver coming with 7.3).

From time to time out of the blue the DataSource seems to deliver broken
connections.

java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69
)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
        at org.postgresql.PG_Stream.flush(PG_Stream.java:352)
        at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:154)
        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Con
nection.java:505)
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stat
ement.java:320)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat
ement.java:48)
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc
1Statement.java:153)
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc
1Statement.java:141)
        at
org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
atement.java:162)
    at ....

Sometimes I find an error in the catalina and in the postgres log indicating
that *one* statement got garbled (SQL syntax error). It looks like this:

ERROR:  parser: unterminated quoted string at or near "'Ort: xxxxxxxxxxxx" at
character 52
FATAL:  Socket command type ' unknown

From then on, nothing reaches postgres any more.

I am quite confident that the servlet itself is thread safe, and the statement
being sent is (afaict) correct (everything nicely escaped and such). Moreover
such an error should not break all connections in the pool, should it?

Has anyone observed similar behaviour? What can I do to narrow down the bug
in order to blame the right one? :-)

With kind regards / mit freundlichem Gruß
    Holger Klawitter
--
Holger Klawitter                          http://www.klawitter.de
lists@klawitter.de

Re: DataSource suddenly drops all connections?

От
Barry Lind
Дата:
Holger,

Have you tried the latest jdbc build for 7.3 from the website?  There
was a recent bug fix that looks similar to what you are reporting here.

thanks,
--Barry


Holger Klawitter wrote:
> Hi there,
>
> I've run into a strange problem with Tomcat (4.1.12; JDK 1.4.1_01; Linux
> 2.4.19). My webappliaction connects to a postgres database (7.3) via
> javax.sql.DataSource (I am using the jdbc driver coming with 7.3).
>
> From time to time out of the blue the DataSource seems to deliver broken
> connections.
>
> java.net.SocketException: Broken pipe
>         at java.net.SocketOutputStream.socketWrite0(Native Method)
>         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
>         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
>         at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69
> )
>         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
>         at org.postgresql.PG_Stream.flush(PG_Stream.java:352)
>         at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:154)
>         at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
>         at
> org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Con
> nection.java:505)
>         at
> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stat
> ement.java:320)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat
> ement.java:48)
>         at
> org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc
> 1Statement.java:153)
>         at
> org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc
> 1Statement.java:141)
>         at
> org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
> atement.java:162)
>     at ....
>
> Sometimes I find an error in the catalina and in the postgres log indicating
> that *one* statement got garbled (SQL syntax error). It looks like this:
>
> ERROR:  parser: unterminated quoted string at or near "'Ort: xxxxxxxxxxxx" at
> character 52
> FATAL:  Socket command type ' unknown
>
> From then on, nothing reaches postgres any more.
>
> I am quite confident that the servlet itself is thread safe, and the statement
> being sent is (afaict) correct (everything nicely escaped and such). Moreover
> such an error should not break all connections in the pool, should it?
>
> Has anyone observed similar behaviour? What can I do to narrow down the bug
> in order to blame the right one? :-)
>
> With kind regards / mit freundlichem Gruß
>     Holger Klawitter
> --
> Holger Klawitter                          http://www.klawitter.de
> lists@klawitter.de
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>




Re: DataSource suddenly drops all connections?

От
Holger Klawitter
Дата:
Hi Barry,

> Have you tried the latest jdbc build for 7.3 from the website?  There
> was a recent bug fix that looks similar to what you are reporting here.

I tried the newest version, it also created the same problem. But I discovered
something new:

The "killer" statement had a (char)0 as part of one argument. The statement
seemed to be broken up into two "packets" being sent to postgres seperately.
I am not sure whether the character originated from a parameter being sent to
the webapp or from tomcat dropping one in or even jdbc doing so (unlikely).

After the sql exception (unterminated ' constant) I got another error only in
postgres (bad socket command ') which was probably from the beginning of the
"second" packet.

This results in the jdbc driver to be utterly confused and closing all
connection sockets.

Right now I've added an input filter against char 0's ...

With kind regards / mit freundlichem Gruß
    Holger Klawitter
--
Holger Klawitter                          http://www.klawitter.de
lists@klawitter.de

Re: DataSource suddenly drops all connections?

От
P G
Дата:
You wouldn't have happened to get any "Broken pipe"
errors like the following, because I am having a
problem with this and cannot figure out what is
causing it?

java.sql.SQLException: IOError while reading from
backend:
 java.net.SocketException: Broken pipe
         at
postgresql.PG_Stream.ReceiveChar(PG_Stream.java:183)
         at
postgresql.Connection.ExecSQL(Connection.java:668)
         at
postgresql.Connection.setAutoCommit(Connection.java:377)


--- Holger Klawitter <lists@klawitter.de> wrote:
> Hi Barry,
>
> > Have you tried the latest jdbc build for 7.3 from
> the website?  There
> > was a recent bug fix that looks similar to what
> you are reporting here.
>
> I tried the newest version, it also created the same
> problem. But I discovered
> something new:
>
> The "killer" statement had a (char)0 as part of one
> argument. The statement
> seemed to be broken up into two "packets" being sent
> to postgres seperately.
> I am not sure whether the character originated from
> a parameter being sent to
> the webapp or from tomcat dropping one in or even
> jdbc doing so (unlikely).
>
> After the sql exception (unterminated ' constant) I
> got another error only in
> postgres (bad socket command ') which was probably
> from the beginning of the
> "second" packet.
>
> This results in the jdbc driver to be utterly
> confused and closing all
> connection sockets.
>
> Right now I've added an input filter against char
> 0's ...
>
> With kind regards / mit freundlichem Gru�
>     Holger Klawitter
> --
> Holger Klawitter
> http://www.klawitter.de
> lists@klawitter.de
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/