NodeReindexServiceThread might be starting too early

Hello,
We’re occasionally seeing errors during Jira startup related to plugin not being completely initialized when NodeReindexServiceThread re-indexing some of fields related to our Jira plugin.

We’re waiting for several events to happen before running initialization of plugin services:

  1. LifecycleAware#onStart
  2. PluginEnabledEvent for current plugin
  3. Spring @PostConstruct

The complete initialization code is available here

I’m not sure whether this is expected (and correct) behaviour or not. If this is how it should be working, we’ll consider changing the ways we initialize plugin services to avoid such issues.

@ayakovlev - can you please take a look at this and see if there’s anything you can recommend?

This problem looks similar to one described in https://jira.atlassian.com/browse/JRASERVER-67619

Start of the NodeReindexServiceThread:thread-1 is not synchronized with start-up thread, it just has 10sec delay. In some conditions, this time will be not enough and this could lead to the contention of the resources and possible start-up failure

Not sure how to workaround this easily.

It doesn’t look like the same issue, I think, but it might be relevant. In the issue you’ve linked it causes Jira not to start correctly.

I haven’t tested this, but it’s likely that node reindex service is currently started before lifecycleaware onstart is triggered, which causes the issue with our plugin. What I wanted to know, whether this behaviour is correct or not.

Yep, the reason I linked was a bit different, I wanted to highlight the fact that NodeReindexServiceThread:thread-1 is not synchronized with start-up thread, it started just 10 seconds later.

What it could mean in your case that:

node reindex service is currently started before lifecycleaware onstart is triggered

Hope this makes more sense now.