Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-78768

Async webhooks do not use request cache in Jira Data Center (Invalid use of RequestCache by thread: webhook-dispatcher)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 10.3.6, 10.6.1, 10.7.0
    • 9.0.0, 9.4.0, 9.12.0, 10.0.0, 10.3.0, 10.3.3, 10.3.5, 10.6.0
    • Webhooks
    • 9
    • 13
    • Severity 3 - Minor
    • 70
    • Hide
      Atlassian Update – April 25, 2025

      Hi everyone,

      Thank you for your patience while we worked on this bug. We are pleased to announce its patch, which will soon be available in the following Jira Data Center releases:

      1. 10.3.6 LTS
      2. 10.6.1
      3. 10.7.0

      To receive the fix, you'll need to upgrade Jira to a patched version. If you have any questions, please reach out to our Support Team.

      Show
      Atlassian Update – April 25, 2025 Hi everyone, Thank you for your patience while we worked on this bug. We are pleased to announce its patch, which will soon be available in the following Jira Data Center releases: 10.3.6 LTS 10.6.1 10.7.0 To receive the fix, you'll need to upgrade Jira to a patched version. If you have any questions, please reach out to our Support Team .

      Issue Summary

      Asynchronous webhooks use Jira’s request cache outside of the appropriate context. This causes the webhook executor to generate the JSON payload without access to some caches.

      As a consequence, environments with heavy webhook utilization may observe some combination of:

      1. Delays in webhook delivery
      2. Excessive database pressure
      3. Dropped webhooks due to queue/service limits

      Async webhooks are opt-in in Jira 9 via a feature flag and the only option in Jira 10.

      Note on Invalid use of RequestCache errors

      See JRASERVER-72963#comment-3059444 for more details.

      Note: There is a whole family of "Invalid use of RequestCache by thread..." issues, one per thread. Find the one you need or file a new one.

      Steps to Reproduce

      1. Configure one or more [issue event] webhooks, including the JSON payload.
      2. Induce a high-load (100+ updates/seconds) of matching events.

      Expected Results

      The webhook executor can process each webhook and build its payload body in a reasonable amount of time. Database pressure is reasonable.

      Actual Results

      Call stacks that should otherwise quickly return with cached values are delayed. This can observed in thread dumps:

      Frames with stacks that pass through a cached resource

      Frames with stacks that perform a database query

      Request cache warning

      A warning can be observed in the atlassian-jira.log after the first webhook is fired on each thread after node startup:

      Jira 9 (async webhooks enabled via feature flag)
      2025-04-22 14:30:00,000+0000 Web-Hook-Events-Processor-1 ERROR      [c.a.j.cache.request.RequestCacheRecorderImpl] Invalid use of RequestCache by thread: Web-Hook-Events-Processor.Incorrect usage of JIRA API. You can only create/use: RequestCacheImpl inside a context (request or Jira-Thread-Local). Check: JiraThreadLocalUtil for details. This message will be logged once per thread. This ERROR should be fixed on the caller side (check the stack-trace or thread-name) as it is causing inconsistent data.
      java.lang.Throwable
      	at com.atlassian.jira.cache.request.RequestCacheRecorderImpl.errorLogOOCThreadUsage(RequestCacheRecorderImpl.java:32)
      	at com.atlassian.jira.cache.request.RequestCacheRecorderImpl.recordRequestCacheOOCUsage(RequestCacheRecorderImpl.java:25)
      	at com.atlassian.jira.cache.request.RequestCacheImpl.get(RequestCacheImpl.java:47)
      	[...]
      	at com.atlassian.jira.plugins.webhooks.serializer.IssueEventSerializer.putFields(IssueEventSerializer.java:59)
      	at com.atlassian.jira.plugins.webhooks.serializer.IssueEventSerializer.putFields(IssueEventSerializer.java:28)
      	at com.atlassian.jira.plugins.webhooks.serializer.AbstractJiraEventSerializer.serialize(AbstractJiraEventSerializer.java:28)
      	at com.atlassian.webhooks.plugin.module.WebHookEventSerializer.serialize(WebHookEventSerializer.java:32)
      	at com.atlassian.webhooks.plugin.PublishTaskFactoryImpl.getEventBody(PublishTaskFactoryImpl.java:67)
      	at com.atlassian.webhooks.plugin.PublishTaskFactoryImpl.getPublishTask(PublishTaskFactoryImpl.java:61)
      	at com.atlassian.webhooks.plugin.WebHookPublisherImpl.publish(WebHookPublisherImpl.java:116)
      	at com.atlassian.webhooks.plugin.WebHookPublisherImpl.publish(WebHookPublisherImpl.java:83)
      	at com.atlassian.webhooks.plugin.WebHookEventsProcessor.lambda$null$2(WebHookEventsProcessor.java:115)
      	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      	at java.base/java.lang.Thread.run(Thread.java:840)
      
      Jira 10
      2025-04-22 14:30:00,000+0000 webhook-dispatcher:thread-1 ERROR      [c.a.j.cache.request.RequestCacheRecorderImpl] Invalid use of RequestCache by thread: webhook-dispatcher:thread.Incorrect usage of JIRA API. You can only create/use: RequestCacheImpl inside a context (request or Jira-Thread-Local). Check: JiraThreadLocalUtil for details. This message will be logged once per thread. This ERROR should be fixed on the caller side (check the stack-trace or thread-name) as it is causing inconsistent data.
      java.lang.Throwable
      	at com.atlassian.jira.cache.request.RequestCacheRecorderImpl.errorLogOOCThreadUsage(RequestCacheRecorderImpl.java:32)
      	at com.atlassian.jira.cache.request.RequestCacheRecorderImpl.recordRequestCacheOOCUsage(RequestCacheRecorderImpl.java:25)
      	at com.atlassian.jira.cache.request.RequestCacheImpl.get(RequestCacheImpl.java:46)
      	[...]
      	at com.atlassian.jira.plugins.webhooks.serializer.WebhookJsonEventFactory.lambda$build$19(WebhookJsonEventFactory.java:200)
      	at java.base/java.util.Optional.filter(Optional.java:218)
      	at com.atlassian.jira.plugins.webhooks.serializer.WebhookJsonEventFactory.build(WebhookJsonEventFactory.java:200)
      	at com.atlassian.jira.plugins.webhooks.serializer.WebhookJsonEventFactory.build(WebhookJsonEventFactory.java:124)
      	at com.atlassian.jira.plugins.webhooks.spi.JiraWebhookEventPublisher.lambda$onIssueEvent$0(JiraWebhookEventPublisher.java:122)
      	at java.base/java.util.Optional.map(Optional.java:260)
      	at com.atlassian.webhooks.WebhookPublishRequest.getPayload(WebhookPublishRequest.java:154)
      	at com.atlassian.webhooks.internal.publish.DefaultWebhookInvocation.<init>(DefaultWebhookInvocation.java:67)
      	at com.atlassian.webhooks.internal.publish.DefaultWebhookInvocation.<init>(DefaultWebhookInvocation.java:44)
      	at com.atlassian.webhooks.internal.DefaultWebhookService.createSingleInvocationFor(DefaultWebhookService.java:445)
      	at com.atlassian.webhooks.internal.DefaultWebhookService.lambda$createInvocationsFor$15(DefaultWebhookService.java:438)
      	[...]
      	at com.atlassian.webhooks.internal.DefaultWebhookService.createInvocationsFor(DefaultWebhookService.java:439)
      	at com.atlassian.webhooks.internal.DefaultWebhookService.lambda$publish$10(DefaultWebhookService.java:271)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      	at java.base/java.lang.Thread.run(Thread.java:840)
      

      Workaround

      Jira 9

      1. Increase webhook executor thread pool and queue sizes, as described on JRASERVER-74492.
      2. Switch back to synchronous webhooks.

      Jira 10

      Increase webhook executor thread pool and queue sizes, as described on Tuning webhook performance parameters in Jira Data Center.

        1. request-cache-thread-dumps.png
          457 kB
          Benjamin S
        2. jdbc-thread-dumps.png
          458 kB
          Benjamin S

              5d32f8ce8c3b Piotr Juszczyński
              1353e2e9fd2f Benjamin S
              Votes:
              20 Vote for this issue
              Watchers:
              35 Start watching this issue

                Created:
                Updated:
                Resolved: