Sonar

Mysql Broken pipe

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.3, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.5
  • Fix Version/s: 1.5
  • Component/s: Database
  • Labels:
    None
  • Number of attachments :
    0

Description

The rails database connection pool use does not seems to use the autoreconnect=true jdbc url setting and some users experience the following error :

2008.08.26 09:37:40 ERROR rails.sonar

ActiveRecord::StatementInvalid (ActiveRecord::ActiveRecordError:
Communications link failure due to underlying exception:

    • BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

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:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2744)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3206)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1232)
at jdbc_adapter.JdbcAdapterInternalService$7.call(JdbcAdapterInternalService.java:647)
at jdbc_adapter.JdbcAdapterInternalService.withConnectionAndRetry(JdbcAdapterInternalService.java:241)
at jdbc_adapter.JdbcAdapterInternalService.execute_query(JdbcAdapterInternalService.java:641)
at jdbc_adapter.JdbcAdapterInternalServiceInvoker$execute_query_s_method_0_0.call(Unknown
Source)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodNoBlock.call(JavaMethod.java:63)
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:78)
at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:329)
at org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:649)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:324)
at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)
at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:309)
at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:363)
at org.jruby.evaluator.ASTInterpreter.fCallNode(ASTInterpreter.java:1120)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:370)
at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)
at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:150)
at org.jruby.runtime.Block.yield(Block.java:114)
at org.jruby.evaluator.ASTInterpreter.yieldNode(ASTInterpreter.java:1850)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:509)
at org.jruby.evaluator.ASTInterpreter.rescueNode(ASTInterpreter.java:1556)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:468)
at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)
at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150)
at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:275)
at org.jruby.evaluator.ASTInterpreter.fCallNode(ASTInterpreter.java:1139)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:370)
at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)
at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:309)
at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:363) ...

    • END NESTED EXCEPTION **

Last packet sent to the server was 4 ms ago.: SELECT snapshots.`id` AS
t0_r0, snapshots.`created_at` AS t0_r1, snapshots.`project_id` AS
t0_r2, snapshots.`parent_snapshot_id` AS t0_r3, snapshots.`status` AS
t0_r4, snapshots.`purged` AS t0_r5, snapshots.`is
last` AS t0_r6, snapshots.`scope` AS t0_r7, snapshots.`qualifier` AS
t0_r8, snapshots.`root_snapshot_id` AS t0_r9, snapshots.`version` AS
t0_r10, projects.`id` AS t1_r0, projects.`name` AS t1_r1,
projects.`description` AS t1_r2, projects.`enabled` AS t1_r3
, projects.`scope` AS t1_r4, projects.`qualifier` AS t1_r5,
projects.`kee` AS t1_r6, projects.`root_id` AS t1_r7 FROM snapshots
LEFT OUTER JOIN projects ON projects.id = snapshots.project_id WHERE
(islast=1 and projects.enabled=1 and parent_snapshot_id is
null and snapshots.scope='PRJ' and snapshots.status='P') ):
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract_adapter.rb:128:in
`log'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:537:in
`execute'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:597:in
`select'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:522:in
`jdbc_select_all'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/associations.rb:1189:in
`select_all_rows'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/associations.rb:1044:in
`find_with_associations'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/associations.rb:1042:in
`catch'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/associations.rb:1042:in
`find_with_associations'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/base.rb:995:in
`find_every'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/base.rb:418:in
`find'
/var/wimba/sonar-1.4/war/sonar-web/app/models/snapshot.rb:32:in
`last_enabled_projects'
/var/wimba/sonar-1.4/war/sonar-web/app/controllers/project_controller.rb:55:in
`index'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:1101:in
`perform_action'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:696:in
`call_filters'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:688:in
`perform_action_with_filters'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in
`perform_action_with_benchmark'
file:/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/lib/jruby-complete-1.1.2.jar!/benchmark.rb:293:in
`measure'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in
`perform_action_with_benchmark'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:83:in
`perform_action_with_rescue'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:435:in
`process'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:684:in
`process_with_filters'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114:in
`process_with_session_management_support'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:334:in
`process'
/var/wimba/sonar-1.4/war/sonar-web/WEB-INF/gems/gems/rails-1.2.6/lib/dispatcher.rb:41:in
`dispatch'
:1

Activity

Hide
Cédric Munger added a comment -

After some researches, only the rails part is causing problesm since it is not using a database connections pool.
The fix would be to upgrade to rails 2.x so that we can simulate a database conections pool use :

  1. config/initializers/close_connections.rb
    if defined?($servlet_context)
    require 'action_controller/dispatcher'

ActionController::Dispatcher.after_dispatch do
ActiveRecord::Base.clear_active_connections!
end
end

We would also have to set the testOnBorrow pool setting to test the connection is alive when the it is taken from the pool

Currently a few refresh buttons hit is correcting hte problems ar rails reconnects to the database.

Show
Cédric Munger added a comment - After some researches, only the rails part is causing problesm since it is not using a database connections pool. The fix would be to upgrade to rails 2.x so that we can simulate a database conections pool use :
  1. config/initializers/close_connections.rb if defined?($servlet_context) require 'action_controller/dispatcher'
ActionController::Dispatcher.after_dispatch do ActiveRecord::Base.clear_active_connections! end end We would also have to set the testOnBorrow pool setting to test the connection is alive when the it is taken from the pool Currently a few refresh buttons hit is correcting hte problems ar rails reconnects to the database.
Hide
Julien S added a comment -

Just FYI: we had the same problem and we actually removed the autoReconnect=true from the JDBC url, and now... oddly enough, the issue disappeared...

Show
Julien S added a comment - Just FYI: we had the same problem and we actually removed the autoReconnect=true from the JDBC url, and now... oddly enough, the issue disappeared...
Hide
Simon Brandhof added a comment -

A workaround before the patch 1.4.2 is to increase the inactivity delay on mysql server. Default is 8 hours. If sonar is executed once a day, you can increase to 24 hours (interactive_timeout = 86400).

Show
Simon Brandhof added a comment - A workaround before the patch 1.4.2 is to increase the inactivity delay on mysql server. Default is 8 hours. If sonar is executed once a day, you can increase to 24 hours (interactive_timeout = 86400).
Hide
Simon Brandhof added a comment - - edited

The patch 1.4.2 needs a new parameter into conf/sonar.properties. It's the SQL query to validate connections. Its value depends on database :

  • default (embedded)
    sonar.jdbc.validationQuery: values(1)
  • MySql
    sonar.jdbc.validationQuery: select 1
  • Oracle
    sonar.jdbc.validationQuery: select 1 from dual
  • SQL Server
    sonar.jdbc.validationQuery: select 1
Show
Simon Brandhof added a comment - - edited The patch 1.4.2 needs a new parameter into conf/sonar.properties. It's the SQL query to validate connections. Its value depends on database :
  • default (embedded) sonar.jdbc.validationQuery: values(1)
  • MySql sonar.jdbc.validationQuery: select 1
  • Oracle sonar.jdbc.validationQuery: select 1 from dual
  • SQL Server sonar.jdbc.validationQuery: select 1
Hide
Jean-Michel Arnaud added a comment -

I am sorry , but i am still facing the same issue :

after upgrade to sonar 1.4.2 , I have well updated m sonar.properties with and i have

  1. MySql
  2. uncomment the 2 following lines to use MySQL
    sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8
    sonar.jdbc.driver: com.mysql.jdbc.Driver
    sonar.jdbc.validationQuery: select 1

in sonar.log I have still the big stack trace

Show
Jean-Michel Arnaud added a comment - I am sorry , but i am still facing the same issue : after upgrade to sonar 1.4.2 , I have well updated m sonar.properties with and i have
  1. MySql
  2. uncomment the 2 following lines to use MySQL sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 sonar.jdbc.driver: com.mysql.jdbc.Driver sonar.jdbc.validationQuery: select 1
in sonar.log I have still the big stack trace
Hide
Simon Brandhof added a comment -

Very bad news. We'll do some tests again. For the moment I recommend you to apply the above workaround (update a mysql server property).

Show
Simon Brandhof added a comment - Very bad news. We'll do some tests again. For the moment I recommend you to apply the above workaround (update a mysql server property).
Hide
Simon Brandhof added a comment -

There was still one case of failure. It's fixed on sonar 1.5.

Show
Simon Brandhof added a comment - There was still one case of failure. It's fixed on sonar 1.5.
Hide
Wojciech Durczynski added a comment -

Problem still exists on sonar 1.6.

Show
Wojciech Durczynski added a comment - Problem still exists on sonar 1.6.
Hide
Simon Brandhof added a comment -

Can you check that the following parameter is set in sonar.properties ?

sonar.jdbc.validationQuery:                select 1
Show
Simon Brandhof added a comment - Can you check that the following parameter is set in sonar.properties ?
sonar.jdbc.validationQuery:                select 1

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: