Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-13693

IssueUpdateThread fails when processing a long string that matches the Jira issue key regex pattern

    XMLWordPrintable

Details

    Description

      Issue Summary

      IssueUpdateThread fails and gets restarted when processing a long string that matches the Jira issue key regex.

       

      When the thread processes a string over 255 chars that Bitbucket thinks is a Jira issue key, a database exception occurs because the table column for the issue keys has a max limit of 255 chars.

      Table: AO_777666_UPDATED_ISSUES

         Column    |          Type          | Collation | Nullable | Default 
      -------------+------------------------+-----------+----------+---------
       ISSUE       | character varying(255) |           | not null | 
       UPDATE_TIME | bigint                 |           | not null | 0
      

       

      This is reproducible on Data Center: yes

      Steps to Reproduce

      Push a new commit. In the commit message, include a string over 255 chars that matches the Jira issue key regex.

      The default regex pattern is:

      (?<=^|[a-z]\\-|[\\s\\p{Punct}&&[^\\-]])([A-Z][A-Z0-9_]*-\\d+)(?![^\\W_])
      

       

      Sample commit message:

      Test: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST-123
      
      • the string "ABC...RST-123" matches the regex pattern and is processed as a Jira issue key

      Expected Results

      • The IssueUpdateThread does not die
         

      Actual Results

      • The string is matched as a Jira issue key
      • This resulted in a DB exception and caused the IssueUpdateThread to be restarted.

      The below exception is thrown in the atlassian-bitbucket.log file:

      2023-03-03 15:43:20,947 WARN  [IssueUpdateThread]  c.a.s.i.j.index.IssueUpdateProcessor IssueUpdateThread failed; the thread will be restarted
      com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
      Database:
      	- name:PostgreSQL
      	- version:11.15
      	- minor version:15
      	- major version:11
      Driver:
      	- name:PostgreSQL JDBC Driver
      	- version:42.2.20
      
      
      org.postgresql.util.PSQLException: ERROR: value too long for type character varying(255)
      	at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:95)
      	at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.create(TenantAwareActiveObjects.java:267)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at com.atlassian.stash.internal.jira.index.ao.AoUpdatedIssuesDao.lambda$update$1(AoUpdatedIssuesDao.java:40)
      	at java.lang.Iterable.forEach(Iterable.java:75)
      	at com.atlassian.stash.internal.jira.index.ao.AoUpdatedIssuesDao.update(AoUpdatedIssuesDao.java:37)
      	at com.atlassian.stash.internal.jira.index.IssueUpdateProcessor.lambda$processQueue$0(IssueUpdateProcessor.java:171)
      	at com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:21)
      	at com.atlassian.stash.internal.sal.spi.HostContextAccessorImpl.doInTransaction(HostContextAccessorImpl.java:54)
      	at com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at com.atlassian.stash.internal.jira.index.IssueUpdateProcessor.processQueue(IssueUpdateProcessor.java:170)
      	at com.atlassian.stash.internal.jira.index.IssueUpdateProcessor.lambda$createThread$1(IssueUpdateProcessor.java:181)
      	at java.lang.Thread.run(Thread.java:750)
      	... 47 frames trimmed
      Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(255)
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
      	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
      	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
      	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
      	at net.java.ao.ForwardingPreparedStatement.executeUpdate(ForwardingPreparedStatement.java:45)
      	at net.java.ao.ParameterMetadataCachingPreparedStatement.executeUpdate(ParameterMetadataCachingPreparedStatement.java:10)
      	at net.java.ao.db.PostgreSQLDatabaseProvider.executeInsertReturningKey(PostgreSQLDatabaseProvider.java:336)
      	at net.java.ao.DatabaseProvider.insertReturningKey(DatabaseProvider.java:1867)
      	at net.java.ao.db.PostgreSQLDatabaseProvider.insertReturningKey(PostgreSQLDatabaseProvider.java:298)
      	at net.java.ao.EntityManager.create(EntityManager.java:369)
      	at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:93)
      	... 23 common frames omitted 

      Workaround

      Set a custom Jira issue key pattern that limits the number of characters used for matching.

      See: Integrating with custom JIRA issue key in Bitbucket Server
       

      Attachments

        Issue Links

          Activity

            People

              khughes@atlassian.com Kristy
              jmariano@atlassian.com JP Mariano
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: