Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-19135

Should we drop MySQL's autoReconnect=true from Confluence?

    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      MySQL documentation discourage using the autoReconnect parameter:

      The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, investigate setting the MySQL server variable "wait_timeout" to some high value rather than the default of 8 hours.

      However we make this parameter set to true by default upon installation of Confluence.

      In JIRA, this parameter has been dropped and deemed useless: JRA-15731

      If this also applies to Confluence, we should also do the same and update our documentation.

            [CONFSERVER-19135] Should we drop MySQL's autoReconnect=true from Confluence?

            SarahA added a comment -

            Documentation updated and reviewed for Confluence 3.5.
            Created a separate issue for tackling in Confluence 4.0: CONF-22138

            SarahA added a comment - Documentation updated and reviewed for Confluence 3.5. Created a separate issue for tackling in Confluence 4.0: CONF-22138

            Thanks Sarah, the change looks good.

            Stefan Saasen (Inactive) added a comment - Thanks Sarah, the change looks good.

            Thanks Sarah!

            Yet another great update from you

            Roy Hartono [Atlassian] added a comment - Thanks Sarah! Yet another great update from you

            SarahA added a comment -

            I have updated the following page:
            http://confluence.atlassian.com/display/DOC/Configuring+a+MySQL+Datasource+in+Apache+Tomcat
            See diff: http://confluence.atlassian.com/pages/diffpages.action?pageId=1867&originalId=235670132

            I have also searched the DOC and CONFKB spaces for other pages that may need updating, and not found any.

            Stefan, please would you review the change?

            SarahA added a comment - I have updated the following page: http://confluence.atlassian.com/display/DOC/Configuring+a+MySQL+Datasource+in+Apache+Tomcat See diff: http://confluence.atlassian.com/pages/diffpages.action?pageId=1867&originalId=235670132 I have also searched the DOC and CONFKB spaces for other pages that may need updating, and not found any. Stefan, please would you review the change?

            DataSource

            validationQuery

            Setting the validationQuery attribute to valid query for MySQL (e.g. "SELECT 1") prevents connection problems when using a data source in Tomcat (version tested is Tomcat 6.0.26 as used in Confluence 3.4 standalone) which is using DBCP.

            autoReconnect is not required for this configuration.

                                <Resource name="jdbc/confluence" auth="Container" type="javax.sql.DataSource"
                                    username="USER"
                                    password="PASSWORD"
                                    driverClassName="com.mysql.jdbc.Driver"
                                    url="jdbc:mysql://localhost:3306/confluence?useUnicode=true&amp;characterEncoding=utf8"
                                    maxActive="15"
                                    maxIdle="7"
                                    validationQuery="Select 1" />
            
            

            Note: Setting the validationQuery option on the database connection pool will have a performance impact as DBCP will use this query to validate connections before returning them to the caller.

            Using autoReconnect without using the validationQuery does not prevent {{com.mysql.jdbc.exceptions.jdbc4.CommunicationsException}}s!

            We should remove autoReconnect from our docs and setup instructions.

            Stefan Saasen (Inactive) added a comment - DataSource validationQuery Setting the validationQuery attribute to valid query for MySQL (e.g. "SELECT 1") prevents connection problems when using a data source in Tomcat (version tested is Tomcat 6.0.26 as used in Confluence 3.4 standalone) which is using DBCP. autoReconnect is not required for this configuration. <Resource name= "jdbc/confluence" auth= "Container" type= "javax.sql.DataSource" username= "USER" password= "PASSWORD" driverClassName= "com.mysql.jdbc.Driver" url= "jdbc:mysql: //localhost:3306/confluence?useUnicode= true &amp;characterEncoding=utf8" maxActive= "15" maxIdle= "7" validationQuery= "Select 1" /> Note : Setting the validationQuery option on the database connection pool will have a performance impact as DBCP will use this query to validate connections before returning them to the caller. Using autoReconnect without using the validationQuery does not prevent {{com.mysql.jdbc.exceptions.jdbc4.CommunicationsException}}s! We should remove autoReconnect from our docs and setup instructions.

            I've checked the linked JRA-15731 issue and the MySQL and DBCP/C3P0 docs. I've done local testing and for the direct JDBC connection (and most likely the DataSource as well) I think we can get rid of the autoReconnect param.

            Environment

            Database version MySQL 5.1.49
            Driver version mysql-connector-java-5.1.11
            Confluence 3.5-m3

            Baseline (Direct JDBC connection)

            In order to reproduce the Communications link failure exceptions I changed the C3P0 pool settings, MySQL server settings and removed the autoReconnect parameter from the JDBC connection URL.

            MySQL server settings

            (/etc/my.cnf), set the wait_timeout (i.e. the number of seconds the server waits for activity on a noninteractive connection before closing it) to 30 seconds:

            • wait_timeout from 28800 -> 30 (seconds)

            C3P0 changes

            • Removed the hibernate.c3p0.idle_test_period setting
            • Changed hibernate.c3p0.timeout -> 60

            JDBC Connection URL

            Removed the autoReconnect=true param.

            jdbc:mysql://localhost/confluence?sessionVariables=storage_engine%3DInnoDB<
            

            *Confluence will log lots of Communications link failure errors.

            Does autoReconnect actually help?

            It doesn't! Running Confluence for a short while still logs lots of errors.

            Does removing autoReconnect cause any problems?

            With the default hibernate.c3p0.timeout settings (hibernate.c3p0.timeout < wait_timeout) and hibernate.c3p0.idle_test_period set autoReconnect doesn't seem to be necessary.

            I haven't found any (which doesn't necessarily mean there aren't any) problems so far.

            I'll check the DataSource approach and check this on our CI builds as well.

            Stefan Saasen (Inactive) added a comment - I've checked the linked JRA-15731 issue and the MySQL and DBCP/C3P0 docs. I've done local testing and for the direct JDBC connection (and most likely the DataSource as well) I think we can get rid of the autoReconnect param. Environment Database version MySQL 5.1.49 Driver version mysql-connector-java-5.1.11 Confluence 3.5-m3 Baseline (Direct JDBC connection) In order to reproduce the Communications link failure exceptions I changed the C3P0 pool settings, MySQL server settings and removed the autoReconnect parameter from the JDBC connection URL. MySQL server settings ( /etc/my.cnf ), set the wait_timeout (i.e. the number of seconds the server waits for activity on a noninteractive connection before closing it) to 30 seconds: wait_timeout from 28800 -> 30 (seconds) C3P0 changes Removed the hibernate.c3p0.idle_test_period setting Changed hibernate.c3p0.timeout -> 60 JDBC Connection URL Removed the autoReconnect=true param. jdbc:mysql: //localhost/confluence?sessionVariables=storage_engine%3DInnoDB< *Confluence will log lots of Communications link failure errors. Does autoReconnect actually help? It doesn't ! Running Confluence for a short while still logs lots of errors. Does removing autoReconnect cause any problems? With the default hibernate.c3p0.timeout settings (hibernate.c3p0.timeout < wait_timeout) and hibernate.c3p0.idle_test_period set autoReconnect doesn't seem to be necessary. I haven't found any (which doesn't necessarily mean there aren't any) problems so far. I'll check the DataSource approach and check this on our CI builds as well.

              smaddox SarahA
              rhartono Roy Hartono [Atlassian]
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: