broken pipe socketexception using mysql persistence

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

broken pipe socketexception using mysql persistence

koenvdk
Hi,


I'm using stable version 3.9.1.201202031753 PE with a mysql persistence config (for all apps and forms).
When the form runner has been idle for a while (I guess the default of 720 minutes), I get exceptions in the log telling me of a broken pipe:


2012-04-10 10:38:27,494 ERROR ProcessorService  - Exception at oxf:/apps/fr/persistence/mysql/search.xpl (executing XSLT transformation)
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3345)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1983)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
        at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5000)
        at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
        at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
        at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:328)
        at org.orbeon.oxf.processor.DatabaseContext.setConnectionProperties(DatabaseContext.java:124)
        at org.orbeon.oxf.processor.DatabaseContext.getConnection(DatabaseContext.java:62)
        at org.orbeon.oxf.processor.sql.SQLProcessorInterpreterContext.getConnection(SQLProcessorInterpreterContext.java:334)
        at org.orbeon.oxf.processor.sql.interpreters.QueryInterpreter.end(QueryInterpreter.java:173)
        at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:540)
        at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
        at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
        at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
        at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
        at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
        at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
        at org.orbeon.oxf.processor.sql.SQLProcessor$RootInterpreter.endElement(SQLProcessor.java:290)
        at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:288)
        at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:202)
... and so on



When this happens, I also get "no results" (empty table) in the browser, instead of an error message.

When searching about the exception, I came upon this:
http://mikeschubert.com/2006/08/03/javanetsocketex/

I think this might be what's happening: orbeon has a connection to the database because of doing a query without commiting it, time passes, and the connection gets broken. When refreshing the browser a few times after waiting a minute, things start to work again, as a new connection is made. However, in a production environment, this cannot be tolerated.

I guess I could circumvent the problem doing something like (tomcat configuration of the jdbc resource):


<Resource name="jdbc/mysqldb"
          auth="Container"
          type="javax.sql.DataSource"
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/D01?autoReconnect=true"
          username="tomcat"
          password="tomcat"
          maxActive="20"
          maxIdle="30"
          maxWait="-1"
/>


Keeping maxwait at -1 means wait indefinitely, so all connections can remain open. But this would probably deteriorate the db connection after a while.



Am I completely wrong about what this error means, or does the orbeon mysql persistence service forget to commit its queries? (I know, it's strange having to commit queries)
Will there be a fix?


Thank you,



Koen Vanderkimpen

Connect: Twitter








Overeenkomstig de bepalingen inzake de vertegenwoordiging van de vzw in haar statuten, kan enkel de gedelegeerde bestuurder, de algemeen directeur of zijn uitdrukkelijke lasthebber verbintenissen aangaan namens Smals.
Indien dit bericht niet voor u bestemd is, verzoeken wij u dit onmiddellijk aan ons te melden en het bericht te vernietigen.

Conformément aux dispositions relatives à la représentation de l'asbl dans ses statuts, seul l'administrateur délégué, le directeur général ou son mandataire exprès est habilité à souscrire des engagements au nom de Smals.
Si ce message ne vous est pas destiné, nous vous prions de nous le signaler immédiatement et de détruire le message.

According to the provisions regarding representation of the non profit association in its bylaws, only the chief executive officer, the general manager or his explicit agent can enter into engagements on behalf of Smals.
If you are not the addressee of this message, we kindly ask you to signal this to us immediately and to delete the message.





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: broken pipe socketexception using mysql persistence

Alessandro  Vernet
Administrator
Hi Koen,

Orbeon Forms keeps connections it borrows from the pool only for a
duration of an HTTP request. But what happens with MySQL (and any SQL
database, AFAIK), is that if the pool keeps a connection open to the
database for a long time without using it, the connection might get
closed, and Tomcat won't know about it until the next time it sends a
request. So I suggest you add validationQuery="select 1" to your
attributes. With this, the pool will check that the connection is
still valid before lending it to Orbeon Forms.

There is a cost to this additional query, but it is most likely
negligible for our use case. (It is possible to almost entirely get
rid of this cost by brining an "evictor" in the picture, which
periodically checks that the idle connections in the pool are valid.
But for now I would stay away from it, because again, in our case, the
cost of this additional "select 1" is most likely negligible.)

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html

Alex


On Tue, Apr 10, 2012 at 2:14 AM, <[hidden email]> wrote:

>
> Hi,
>
>
> I'm using stable version 3.9.1.201202031753 PE with a mysql persistence
> config (for all apps and forms).
> When the form runner has been idle for a while (I guess the default of 720
> minutes), I get exceptions in the log telling me of a broken pipe:
>
>
> 2012-04-10 10:38:27,494 ERROR ProcessorService  - Exception at
> oxf:/apps/fr/persistence/mysql/search.xpl (executing XSLT transformation)
> java.net.SocketException: Broken pipe
>         at java.net.SocketOutputStream.socketWrite0(Native Method)
>         at
> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
>         at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
>         at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
>         at
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
>         at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3345)
>         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1983)
>         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
>         at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
>         at
> com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5000)
>         at
> org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
>         at
> org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
>         at
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:328)
>         at
> org.orbeon.oxf.processor.DatabaseContext.setConnectionProperties(DatabaseContext.java:124)
>         at
> org.orbeon.oxf.processor.DatabaseContext.getConnection(DatabaseContext.java:62)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessorInterpreterContext.getConnection(SQLProcessorInterpreterContext.java:334)
>         at
> org.orbeon.oxf.processor.sql.interpreters.QueryInterpreter.end(QueryInterpreter.java:173)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:540)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
>         at
> org.orbeon.oxf.processor.sql.SQLProcessor$RootInterpreter.endElement(SQLProcessor.java:290)
>         at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:288)
>         at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:202)
> ... and so on
>
>
>
> When this happens, I also get "no results" (empty table) in the browser,
> instead of an error message.
>
> When searching about the exception, I came upon this:
> http://mikeschubert.com/2006/08/03/javanetsocketex/
>
> I think this might be what's happening: orbeon has a connection to the
> database because of doing a query without commiting it, time passes, and the
> connection gets broken. When refreshing the browser a few times after
> waiting a minute, things start to work again, as a new connection is made.
> However, in a production environment, this cannot be tolerated.
>
> I guess I could circumvent the problem doing something like (tomcat
> configuration of the jdbc resource):
>
>
> <Resource name="jdbc/mysqldb"
>           auth="Container"
>           type="javax.sql.DataSource"
>           driverClassName="com.mysql.jdbc.Driver"
>           url="jdbc:mysql://localhost:3306/D01?autoReconnect=true"
>           username="tomcat"
>           password="tomcat"
>           maxActive="20"
>           maxIdle="30"
>           maxWait="-1"
> />
>
> Keeping maxwait at -1 means wait indefinitely, so all connections can
> remain open. But this would probably deteriorate the db connection after a
> while.
>
>
>
> Am I completely wrong about what this error means, or does the orbeon
> mysql persistence service forget to commit its queries? (I know, it's
> strange having to commit queries)
> Will there be a fix?
>
>
> Thank you,
>
>
>
> Koen Vanderkimpen
>
> Connect:
>
>
>
>
>
> ________________________________
>
>
> Overeenkomstig de bepalingen inzake de vertegenwoordiging van de vzw in
> haar statuten, kan enkel de gedelegeerde bestuurder, de algemeen directeur
> of zijn uitdrukkelijke lasthebber verbintenissen aangaan namens Smals.
> Indien dit bericht niet voor u bestemd is, verzoeken wij u dit
> onmiddellijk aan ons te melden en het bericht te vernietigen.
>
> Conformément aux dispositions relatives à la représentation de l'asbl dans
> ses statuts, seul l'administrateur délégué, le directeur général ou son
> mandataire exprès est habilité à souscrire des engagements au nom de Smals.
> Si ce message ne vous est pas destiné, nous vous prions de nous le
> signaler immédiatement et de détruire le message.
>
> According to the provisions regarding representation of the non profit
> association in its bylaws, only the chief executive officer, the general
> manager or his explicit agent can enter into engagements on behalf of Smals.
> If you are not the addressee of this message, we kindly ask you to signal
> this to us immediately and to delete the message.
>
>


--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet