Sonar每隔几天停止工作:jdbc连接错误

时间:2014-01-02 14:16:10

标签: java maven jdbc jenkins sonarqube

我有一个Sonar服务器,每天从maven / jenkins使用一次,每隔几天,比如每4或5天,它会崩溃并显示消息“我们很抱歉,但出了点问题”。< / p>

在日志中,错误总是与jdbc连接问题有关。我认为这是数据库的问题,但是如果我重新启动声纳服务器,一切都会好起来的。

因此,它看起来像是内存泄漏或声纳服务器中的某些内容,每隔几天就会崩溃,直到有人重新启动它。这有道理吗?这是我的配置:

sonar.jdbc.username: xxxx
sonar.jdbc.password: xxxx
sonar.jdbc.url: jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
#----- Connection pool settings
sonar.jdbc.maxActive:                      20
sonar.jdbc.maxIdle:                        5
sonar.jdbc.minIdle:                        2
sonar.jdbc.maxWait:                        5000
sonar.jdbc.minEvictableIdleTimeMillis:     600000
sonar.jdbc.timeBetweenEvictionRunsMillis:  30000

sonar.updatecenter.activate=true

http.proxyHost=xxxx
http.proxyPort=3128

sonar.notifications.delay=60

就是这样。这是错误日志:

INFO  o.s.s.p.ServerImpl  SonarQube Server / 3.7.3 / 
INFO  o.s.c.p.Database  Create JDBC datasource for jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

ERROR o.s.c.p.Database  Can not connect to database.
Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').

org.apache.commons.dbcp.SQLNestedException: 
Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
.
.
.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
.
.
.
Caused by: java.net.ConnectException: Connection refused
.
.
.
INFO  jruby.rack  An exception happened during JRuby-Rack startup
no connection available
--- System
jruby 1.6.8 (ruby-1.8.7-p357) (2012-09-18 1772b40) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_43) [linux-amd64-java]
Time: Thu Jan 02 08:04:08 -0500 2014
Server: jetty/7.6.11.v20130520
jruby.home: file:/opt/sonar/war/sonar-server/WEB-INF/lib/jruby-complete-1.6.8.jar!/META-INF/jruby.home

--- Context Init Parameters:
jruby.compat.version = 1.8
jruby.max.runtimes = 1
jruby.min.runtimes = 1
jruby.rack.logging = slf4j
public.root = /
rails.env = production
--- Backtrace
ActiveRecord::ConnectionNotEstablished: no connection available
  set_native_database_types at arjdbc/jdbc/RubyJdbcConnection.java:517
                 initialize at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:61
                 initialize at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31
            jdbc_connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6
                       send at org/jruby/RubyKernel.java:2109
             new_connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223
    checkout_new_connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245
                   checkout at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188
                       loop at org/jruby/RubyKernel.java:1439
                   checkout at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184
            mon_synchronize at file:/opt/sonar/war/sonar-server/WEB-INF/lib/jruby-complete-1.6.8.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191
                   checkout at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183
                 connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98
        retrieve_connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326
        retrieve_connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123
                 connection at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115
                 initialize at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440
                         up at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401
                    migrate at /opt/sonar/war/sonar-server/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383
          upgrade_and_start at /opt/sonar/war/sonar-server/WEB-INF/lib/database_version.rb:62
            automatic_setup at /opt/sonar/war/sonar-server/WEB-INF/lib/database_version.rb:74
                     (root) at /opt/sonar/war/sonar-server/WEB-INF/config/environment.rb:213
                       load at org/jruby/RubyKernel.java:1087
           load_environment at /opt/sonar/war/sonar-server/WEB-INF/config/environment.rb:23
           load_environment at file:/opt/sonar/war/sonar-server/WEB-INF/lib/jruby-rack-1.1.10.jar!/jruby/rack/rails_booter.rb:65
                     (root) at <script>:1

--- RubyGems
Gem.dir: /opt/sonar/war/sonar-server/WEB-INF/gems
Gem.path:
/opt/sonar/war/sonar-server/WEB-INF/gems
Activated gems:
  rake-0.9.2.2
  activesupport-2.3.15
  activerecord-2.3.15
  rack-1.1.3
  actionpack-2.3.15
  actionmailer-2.3.15
  activeresource-2.3.15
  rails-2.3.15
  color-tools-1.3.0
  i18n-0.4.2
  json-jruby-1.2.3-universal-java-1.6
  activerecord-jdbc-adapter-1.1.3
  fastercsv-1.4.0
--- Bundler
undefined method `bundle_path' for Bundler:Module

--- JRuby-Rack Config
compat_version = RUBY1_8
default_logger = org.jruby.rack.logging.StandardOutLogger@4fbbe4e1
err = java.io.PrintStream@d2284af
filter_adds_html = true
filter_verifies_resource = false
ignore_environment = false
initial_memory_buffer_size =
initial_runtimes = 1
jms_connection_factory =
jms_jndi_properties =
logger = org.jruby.rack.logging.Slf4jLogger@566dc8f0
logger_class_name = slf4j
logger_name = jruby.rack
maximum_memory_buffer_size =
maximum_runtimes = 1
num_initializer_threads =
out = java.io.PrintStream@6aeeefcf
rackup =
rackup_path =
rewindable = true
runtime_arguments =
runtime_timeout_seconds =
serial_initialization = false
servlet_context = ServletContext@o.e.j.w.WebAppContext{/,file:/opt/sonar/war/sonar-server/},file:/opt/sonar/war/sonar-server

ERROR jruby.rack  unable to create shared application instance
org.jruby.rack.RackInitializationException: no connection available
.
.
.
org.jruby.exceptions.RaiseException: 
(ConnectionNotEstablished) no connection available
.
.
.
ERROR jruby.rack  Error: application initialization failed
org.jruby.rack.RackInitializationException: no connection available
.
.
.
org.jruby.exceptions.RaiseException:
(ConnectionNotEstablished) no connection available

任何帮助将不胜感激:)

2 个答案:

答案 0 :(得分:0)

这听起来很熟悉:P尝试询问您的操作员是否进行了一些自动“清理”操作,该操作只会定期自动打开数据库连接,以防止泄漏到数据库的连接。

答案 1 :(得分:0)

在我不同的服务器上的Windows 2012 Server和SQL Server 2012数据库中发生了这种情况。似乎声纳服务维持一个连接打开,在启动时创建,因此任何断开连接(网络,数据库重启等)都会导致这种不可恢复的连接问题。重新启动Sonar(SonarQube)Windows服务解决了我的问题。但是,如果这个问题很常见,就像在你的情况下一样,最好安排一个服务重启任务,或者找出关闭连接的内容。