diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-09-09 13:21:04 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-09-09 13:30:21 +0200 |
commit | 13584d1c510bfe65d631fa38c3276188f606e575 (patch) | |
tree | f4c0532342bdf0ee4787e5b0c839fbc2a016c537 /sonar-server/src/main | |
parent | 89ed7ca079f1db2c362fbee7fcd835995d68a46d (diff) | |
download | sonarqube-13584d1c510bfe65d631fa38c3276188f606e575.tar.gz sonarqube-13584d1c510bfe65d631fa38c3276188f606e575.zip |
SONAR-2784 When the maximum number of JDBC connections is reached some JDBC connections are never released to the JDBC pool
Diffstat (limited to 'sonar-server/src/main')
3 files changed, 15 insertions, 3 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 485a7a1b341..297f1b23413 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -284,8 +284,13 @@ public final class JRubyFacade { return getContainer().getComponent(ServerKeyGenerator.class).generate(organization, ipAddress); } - public Connection getConnection() throws SQLException { - return getContainer().getComponent(DatabaseConnector.class).getConnection(); + public Connection getConnection() { + try { + return getContainer().getComponent(DatabaseConnector.class).getConnection(); + } catch (Exception e) { + /* activerecord does not correctly manage exceptions when connection can not be opened. */ + return null; + } } public Object getCoreComponentByClassname(String className) { diff --git a/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/callbacks.rb b/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/callbacks.rb index 68733ab811b..27375c60a68 100644 --- a/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/callbacks.rb +++ b/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/callbacks.rb @@ -37,7 +37,12 @@ module ActiveRecord end def on_checkout - reconnect! + #sonar + # Why do we try to reconnect ? It opens two connections instead of a single one. + # Commenting the reconnection allows to have a single JDBC connection per HTTP request + # https://jira.codehaus.org/browse/SONAR-2784 + #reconnect! + #/sonar end end end diff --git a/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb b/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb index afc8cb202b0..cc53739470d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb +++ b/sonar-server/src/main/webapp/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb @@ -13,6 +13,8 @@ module ActiveRecord config[:connection_alive_sql] ||= "select 1" # sonar + # ActiveRecord must transfer the responsibility of connection pool to the Sonar, + # even if JNDI datasource is not used. @jndi_connection = true # /sonar @connection = nil |