Uploaded image for project: 'Jira Cloud'
  1. Jira Cloud
  2. JRACLOUD-45794

ConnectionPoolHealthSqlInterceptor logs "dangerous" warnings if thread holds database connection for 5 minutes

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for JIRA Cloud. Using JIRA Server? See the corresponding bug report.

      If a background thread holds a database connection for more than five minutes, the ConnectionPoolHealthSqlInterceptor gets confused with a "-2" low-water mark and it dumps seemingly-incorrect warnings in the logs.

      For example, when testing a background thread that was using a connection for five minutes, the ConnectionPoolHealthSqlInterceptor logged the following in relation to an Atlassian-internal OFBIZ call. The stack trace shows that it corresponds to a connection closed within GenericDAO#select (triggered by a IssueManager#getIssueObject):

      2015-10-15 13:39:41,827 dataplane-CHCT-3 WARN      [c.a.jira.ofbiz.ConnectionPoolHealthSqlInterceptor] Dangerous use of multiple connections: replaced => count=-1; marks=[-2-0]; pool=1/20
      

      Note the low water mark of "-2".

      The ConnectionPoolHealthSqlInterceptor creates a CountHolder inner class which causes the ThreadLocal to self-destruct after five minutes. Subsequent to that self-destruction, the next connection to be returned to the pool (which is probably the connection for which the taken() method was just previously called) calls the replaced() method, which does not check to see if the low water mark is below zero, and which causes this warning to be logged.

      I suppose that the answer could easily be "we don't want your thread to hold database connections for more than 5 minutes", but that notwithstanding, it looks like ConnectionPoolHealthSqlInterceptor is not working quite as intended in this scenario.

      Attachments

        Issue Links

          Activity

            People

              ohernandez@atlassian.com Oswaldo Hernandez (Inactive)
              7c60ab039b09 Scott Dudley [Inactive]
              Votes:
              12 Vote for this issue
              Watchers:
              44 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: