Uploaded image for project: 'Jira Server and Data Center'
  1. Jira Server and Data Center
  2. JRASERVER-46026

JIRA is unable to check collation on certain JDBC URLs

    XMLWordPrintable

Details

    Description

      Summary

      On startup, JIRA attempts to perform a collation check. In certain scenarios this check will fail as the database name is incorrectly parsed from the JDBC URL. It can present with different errors depending upon the DBMS used.

      Environment

      Reproduced with PostgreSQL 9.1 using the below JDBC URL:

      jdbc:postgresql://localhost:5432/jira700?ssl=true
      

      The below JDBC URL was reported as problematic however not reproduced:

      jdbc:jtds:sqlserver://example.com:1433;databaseName=Jira
      

      Steps to Reproduce

      1. Setup PostgreSQL to serve with SSL.
        • Generate certificates.
        • Edit postgresql.conf to use SSL, and optionally set the certificate location or put them in the <pg_install>/data directory.
        • Restart PostgreSQL.
        • Add ?ssl=true to the JDBC url.
      2. Start JIRA.

      Expected Results

      It is able to correctly read the collation.

      Actual Results

      The error below will appear:

          ****************************************************************************************************
          The database collation could not be read. An unsupported collation could cause some functionality to not work
          ****************************************************************************************************
      

      And will have a corresponding exception depending upon the DBMS used. JIRA will still start up.

      PostgreSQL
      2015-10-21 22:06:10,507 localhost-startStop-1 INFO      [c.a.j.appconsistency.db.CollationCheck] Exception when reading database collation
      org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
      	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkResultSet(AbstractJdbc2ResultSet.java:2695)
      	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:1872)
      	at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
      	at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
      	at com.atlassian.jira.database.DatabaseCollationReader.findCollation(DatabaseCollationReader.java:46)
      	at com.atlassian.jira.appconsistency.db.CollationCheck.isOk(CollationCheck.java:60)
      	at com.atlassian.jira.startup.JiraDatabaseConfigChecklist.doStartupChecks(JiraDatabaseConfigChecklist.java:72)
      	at com.atlassian.jira.startup.JiraDatabaseConfigChecklist.startupOK(JiraDatabaseConfigChecklist.java:60)
      	at com.atlassian.jira.startup.DatabaseChecklistLauncher.start(DatabaseChecklistLauncher.java:46)
      	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$postDbLaunch$174(DefaultJiraLauncher.java:123)
      	at com.atlassian.jira.startup.DefaultJiraLauncher$$Lambda$9/1032956955.run(Unknown Source)
      	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:356)
      	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseConfigured(DatabaseConfigurationManagerImpl.java:232)
      	at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:122)
      	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$start$173(DefaultJiraLauncher.java:92)
      	at com.atlassian.jira.startup.DefaultJiraLauncher$$Lambda$1/853477245.run(Unknown Source)
      	at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:34)
      	at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:90)
      	at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:84)
      	... 5 filtered
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      Or:

      MS SQL Server
      2015-10-23 13:36:17,610 localhost-startStop-1 INFO      [jira.appconsistency.db.CollationCheck] Exception when reading database collation
      java.sql.SQLException: No current row in the ResultSet.
              at net.sourceforge.jtds.jdbc.JtdsResultSet.getColumn(JtdsResultSet.java:285)
              at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:952)
              at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
              at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
              at com.atlassian.jira.database.DatabaseCollationReader.findCollation(DatabaseCollationReader.java:46)
              at com.atlassian.jira.appconsistency.db.CollationCheck.isOk(CollationCheck.java:60)
              at com.atlassian.jira.startup.JiraDatabaseConfigChecklist.doStartupChecks(JiraDatabaseConfigChecklist.java:72)
              at com.atlassian.jira.startup.JiraDatabaseConfigChecklist.startupOK(JiraDatabaseConfigChecklist.java:60)
              at com.atlassian.jira.startup.DatabaseChecklistLauncher.start(DatabaseChecklistLauncher.java:44)
              at com.atlassian.jira.startup.DefaultJiraLauncher$2.run(DefaultJiraLauncher.java:120)
              at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:345)
              at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseConfigured(DatabaseConfigurationManagerImpl.java:221)
              at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:115)
              at com.atlassian.jira.startup.DefaultJiraLauncher.access$100(DefaultJiraLauncher.java:33)
              at com.atlassian.jira.startup.DefaultJiraLauncher$1.run(DefaultJiraLauncher.java:86)
              at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:34)
              at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:81)
              at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:72)
              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
              at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1912)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)
      

      Workaround

      There are reported cases where the ssl=true added in a separate connection-properties parameter instead of the jdbc-url works.

      <url>jdbc:postgresql://xxxxxxx:5432/db</url>
      <connection-properties>ssl=true</connection-properties>
      

      Proceed at your own risk

      Notes

      This exception will not prevent JIRA from starting up, and only occurs if the JDBC URL has additional data appended after it.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dcurrie@atlassian.com Dave C
              Votes:
              36 Vote for this issue
              Watchers:
              54 Start watching this issue

              Dates

                Created:
                Updated: