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

View details on the diagnostics page does not load and fails with Argument data type ntext is invalid for argument 1 of len function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • High
    • 8.3.0, 8.2.2
    • 7.14.4, 7.19.5, 8.1.0, 8.0.2, 7.13.15
    • Server - Jobs

    Description

      Issue Summary

      This is reproducible on Data Center: yes

      The application is not able to load diagnostics details using http[s]://<confluence-host>/plugins/servlet/diagnostics/overview page.

      Environment

      Confluence versions : 7.19+
      Microsoft SQL Server 2019 and 2017

      The issue is not present when Confluence is used with PostgreSQL database.

      Steps to Reproduce

      1. Access http[s]://<confluence-host>/plugins/servlet/diagnostics/overview URL from the broswer
      2. Then click on View Details link for any one of the alerts listed under Confluence Diagnostics

      Expected Results

      The diagnostic details should load and show more information about the alert.

      Actual Results

      The below exception is thrown in the xxxxxxx.log file:

      2023-02-16 15:25:24,083 WARN [http-nio-8090-exec-5] [engine.jdbc.spi.SqlExceptionHelper] logExceptions SQL Error: 8116, SQLState: S0001
       -- url: /rest/diagnostics/latest/alerts/details/JVM-1002/not-detected | userName: admin | referer: http://localhost:8090/plugins/servlet/diagnostics/details/JVM-1002/not-detected | traceId: 436ef5c610faba8e
      2023-02-16 15:25:24,083 ERROR [http-nio-8090-exec-5] [engine.jdbc.spi.SqlExceptionHelper] logExceptions Argument data type ntext is invalid for argument 1 of len function.
       -- url: /rest/diagnostics/latest/alerts/details/JVM-1002/not-detected | userName: admin | referer: http://localhost:8090/plugins/servlet/diagnostics/details/JVM-1002/not-detected | traceId: 436ef5c610faba8e
      .......
      2023-02-16 15:25:24,104 ERROR [http-nio-8090-exec-5] [[Standalone].[localhost].[/].[noop]] log Servlet.service() for servlet [noop] in context with path [] threw exception
      org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
              at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:195)
              at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:370)
              at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:334)
              at com.atlassian.confluence.internal.diagnostics.persistence.dao.hibernate.HibernateAlertEntityDao.withSession(HibernateAlertEntityDao.java:304)
              at com.atlassian.confluence.internal.diagnostics.persistence.dao.hibernate.HibernateAlertEntityDao.streamMinimalAlerts(HibernateAlertEntityDao.java:222)
      .....
      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Argument data type ntext is invalid for argument 1 of len function.
              at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
              at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1624)
              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:594)
              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:524)
              at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
              at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2979)
              at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
              at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:446)
              at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
              at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
              at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
              ... 388 more
      

      The SQL debug logging shows below SQL query failing to pull the data from the DIAGNOSTICS_ALERTS table.

      2023-02-16 14:48:33,876 DEBUG [http-nio-8090-exec-4] [org.hibernate.SQL] logStatement select alertentit0_.id as col_0_0_, alertentit0_.TIMESTAMP as col_1_0_, alertentit0_.ISSUE_ID as col_2_0_, alertentit0_.TRIGGER_PLUGIN_KEY as col_3_0_, alertentit0_.NODE_NAME as col_4_0_, case when alertentit0_.DETAILS_JSON is null then 0 else len(alertentit0_.DETAILS_JSON) end as col_5_0_ from DIAGNOSTICS_ALERTS alertentit0_ where (alertentit0_.ISSUE_ID in (?)) and (alertentit0_.TRIGGER_PLUGIN_KEY_LOWER in (?)) and alertentit0_.TIMESTAMP>0 and alertentit0_.TIMESTAMP<=1676558913847 order by alertentit0_.TIMESTAMP desc, alertentit0_.id desc
      2023-02-16 14:48:33,877 TRACE [http-nio-8090-exec-4] [type.descriptor.sql.BasicBinder] bind binding parameter [1] as [VARCHAR] - [JVM-1002]
      2023-02-16 14:48:33,878 TRACE [http-nio-8090-exec-4] [type.descriptor.sql.BasicBinder] bind binding parameter [2] as [VARCHAR] - [not-detected]
      

      It looks the application is passing the wrong data type (ntext) to a function – in this case, the len() function.

      Workaround

      Currently there is no known workaround for this behavior. A workaround will be added here when available

      Attachments

        1. low-free-memory-example.png
          low-free-memory-example.png
          53 kB
        2. Diagnostics_details.png
          Diagnostics_details.png
          1.11 MB
        3. View_Details_loading.png
          View_Details_loading.png
          322 kB

        Issue Links

          Activity

            People

              5e496a614b63 Diclehan Erdal
              188bae873138 Saurabh
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: