Jira Data Center: Resolve Lucene index errors when upgrading to Jira 11
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Upgrading to Jira 11 from a previous major version (7, 8, 9, 10) requires a full re-index, but Jira doesn’t force a reindex on upgrade, so it may use an incompatible index with problematic results.
Diagnosis
Jira starts; the node either fails to start or starts with apps only partly working: broken gadgets, missing issue side panels, and webhooks that don't fire.
Exceptions are logged like java.lang.IllegalArgumentException: cannot change DocValues type
Cause
The index format changed in Jira 11.0.0
Jira 11.0.0 moved issue indexing to a new field schema. In the process, it changed the Lucene DocValues type of several fields so they can hold more than one value:
Field | Jira 10 | Jira 11 |
Sub-tasks ( |
|
|
Indexed issue properties: string and number |
|
|
Indexed issue properties: date |
|
|
Lucene records a field's DocValues type in the index the first time the field is written, and it can't change that type later. Jira 11 can still open an index built by Jira 10, but it fails as soon as it writes an affected field. That includes indexing any issue that has sub-tasks, or that has issue properties indexed by an app. The error looks like this:
java.lang.IllegalArgumentException: cannot change DocValues type from SORTED_NUMERIC to SORTED_SET for field "issue_subtasks"Jira 10 and Jira 11 both use Lucene 7 and the same index directory, <local-home>/caches/indexesV2. So Jira 11 has nothing on disk that tells it the old index is incompatible. It tries to reuse the index, and fails.
Startup index recovery can't fix it
At startup, each clustered node tries to recover its index by catching up the local index from the database, or by restoring the newest snapshot from <shared-home>/export/indexsnapshots. Both approaches write new documents into a Jira 10 index, so both hit the same IllegalArgumentException. Every snapshot taken before the upgrade has the old format, so trying other snapshots or other nodes doesn't help. Recovery either ends in the blocking "no valid search index" error or falls back to a full re-index during startup. Only a full re-index into an empty index produces a usable Jira 11 index.
Apps are broken because JiraStartedEvent never fires
Apps are enabled during startup, but many of them only finish starting when Jira broadcasts JiraStartedEvent. Jira's SAL implementation waits for that event before it calls apps' LifecycleAware.onStart() and Startable.start() methods. That's where apps typically start background services, register listeners, and warm caches. The webhooks plugin, for example, only starts dispatching webhooks from onStart().
After the index check, Jira runs the upgrade tasks in UpgradeLauncher and then broadcasts JiraStartedEvent. Both steps are skipped if any blocking error is present. An old index can produce a blocking error in two ways:
The index check fails. Jira raises "We could not find a valid search index on the current node".
UpgradeLauncherlogsSkipping, JIRA is locked., so the upgrade tasks don't run andJiraStartedEventisn't sent.The index check is skipped because pending upgrade tasks will trigger a re-index. The old index stays in place, and the
IllegalArgumentExceptionis thrown when an upgrade task writes to it.UpgradeLauncherrecords "An error occurred performing JIRA upgrade", which also blocks startup, soJiraStartedEventisn't sent.
What administrators see depends on whether the error can be dismissed:
Symptom | Cause |
Jira fails to start and shows an error page. | A blocking error is present. The upgrade error can't be dismissed. |
Jira seems to be running, but gadgets are broken, issue side panels are missing, webhooks don't fire, and other app features fail. | An administrator dismissed the "no valid search index" error. Dismissing it removes the error page, but the upgrade tasks and |
Even when the full re-index during startup works, it runs with the app versions from before the upgrade. Data indexed by apps that need updating for Jira 11 can still be missing or wrong afterwards.
Fix: the skip.index.recovery system property (11.3.12+)
-Dcom.atlassian.jira.startup.lucene.skip.index.recovery=true
When this property is set, the node skips all Lucene index recovery during startup. It doesn't catch up, doesn't restore a snapshot, doesn't run a startup re-index, and doesn't raise the blocking error. With no blocking error, the upgrade tasks run, JiraStartedEvent is sent, and apps start fully. The administration UI and the Universal Plugin Manager (UPM) are available, so you can update apps and then run a single full re-index yourself.
Use the property together with deleting the old local index and snapshots, as the procedure below does. With no old index on disk, nothing can throw the IllegalArgumentException, including upgrade tasks that write to the index.
While the property is in effect:
The index is not checked or recovered, so search results on that node are incomplete until the full re-index finishes. Keep users and the load balancer away from the node.
The node doesn't apply index changes sent by other nodes. The full re-index turns this back on. This is why the other nodes must stay down until the re-index is done.
The log shows this warning:
Skipping Lucene index recovery because system property com.atlassian.jira.startup.lucene.skip.index.recovery is set to true.
From 11.3.12, the blocking "no valid search index" error page also explains the upgrade cause and points to this property.
This property is temporary. Use it for one startup on one node only, and remove it as soon as the full re-index finishes. When enabled, the following properties have no effect
com.atlassian.jira.startup.rebuild.local.indexcom.atlassian.jira.startup.pick.indexsnapshot.from.sharedcom.atlassian.jira.startup.request.indexsnapshot.from.another.nodecom.atlassian.jira.startup.allow.full.reindexcom.atlassian.jira.startup.ensure.snapshot.exist
Solution
The procedure below upgrades Jira using the new JVM parameter available in Jira 11.3.12 and above. This will enable apps to initialise correctly and Jira to be reindexed a single time.
Shut down all nodes. Every node must be stopped. A node running Jira 10 can create a new snapshot in the old format while you work.
Upgrade the first node. Upgrade to Jira 11.3.12 or above, but don’t start it
Remove the index snapshots and the local indexes.
Shared home: move the contents of
<shared-home>/export/indexsnapshots/to a backup locationOn every node: move
<local-home>/caches/indexesV2/to a backup location
Add the property on the first node only. In
<install-dir>/bin/setenv.shon Linux, orsetenv.baton Windows:JVM_SUPPORT_RECOMMENDED_ARGS="${JVM_SUPPORT_RECOMMENDED_ARGS} -Dcom.atlassian.jira.startup.lucene.skip.index.recovery=true"If Jira runs as a Windows service, add the property in the service's Java options instead.
Start the first node.Check that
atlassian-jira.logshows the Skipping Lucene index recovery warning and that startup completes. Keep the node out of the load balancer.Upgrade apps, if needed.In Administration › Manage apps, update or replace any apps that aren't compatible with Jira 11. Do this before re-indexing so the index includes data from the correct app versions.
Run a full re-index.Go to Administration › System › Indexing and run a Full re-index, then wait for it to finish. When it's done, the node is creating a fresh Jira 11 snapshot in
<shared-home>/export/indexsnapshots/, and it applies index changes from other nodes again.Remove the property.Delete the property from
setenv.shorsetenv.baton the first node. You don't need to restart now. Removing it makes sure the next restart uses normal index recovery.Start the other nodes on the upgraded Jira version, one at a time.Each node restores the new snapshot from the shared home and catches up from the database. Don't set the property on these nodes. Add nodes back to the load balancer once each one reports that its index is healthy.
Result: The re-index runs once, at a time you choose, with the correct app versions. No node ever tries to reuse a Jira 10 index.
Was this helpful?