Viewing Content Indexing page results in ArithmeticException or NullPointerException
Platform Notice: Data Center Only - This article only applies to Atlassian products 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
Problem
When Confluence administrators try to rebuild the search index via the Content Indexing page in Confluence version 7.7 and above, they'll see the following error message.
We can't check the status of your index. You may have lost your connection. Refresh the page to try again.
Because of this, they would not be able to trigger the index rebuild process.
Arithmetic Exception:
The following error would also appear in the atlassian-confluence.log
2021-11-02 17:09:48,955 ERROR [http-nio-8090-exec-1] [common.error.jersey.ThrowableExceptionMapper] toResponse Uncaught exception thrown by REST service: / by zero
-- referer: https://localhost:8090/plugins/servlet/rebuildindex | url: /rest/rebuildindex/latest/job | traceId: 8a8faee1f9816055 | userName: admin1
java.lang.ArithmeticException: / by zero
at com.atlassian.confluence.plugins.rebuildindex.status.ReIndexJobJson.<init>(ReIndexJobJson.java:65)
at com.atlassian.confluence.plugins.rebuildindex.rest.ReIndexJobResource.lambda$getMostRecentOrRunning$0(ReIndexJobResource.java:46)
at java.base/java.util.Optional.map(Unknown Source)
at com.atlassian.confluence.plugins.rebuildindex.rest.ReIndexJobResource.getMostRecentOrRunning(ReIndexJobResource.java:45)
...
NullPointer Exception
The following error would also appear in the atlassian-confluence.log
2023-07-11 09:23:05,060 ERROR [https-jsse-nio-8443-exec-10] [common.error.jersey.ThrowableExceptionMapper] toResponse Uncaught exception e1dd1bae-b6ac-41e5-957b-2e088f83092a thrown by REST service: null
-- url: /rest/rebuildindex/latest/job | userName: admin | referer: https://localhost:8090/plugins/servlet/rebuildindex | traceId: 91743b933cac0450
java.lang.NullPointerException
at com.atlassian.confluence.plugins.rebuildindex.status.ReIndexNodeStatusJson.<init>(ReIndexNodeStatusJson.java:33)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
...
Diagnosis
By design, Confluence would then invoke the endpoint <Confluence-Base-URL>/plugins/servlet/rebuildindex
when loading up the Content Indexing page. This is to check what's the current status of the reindex for this Confluence cluster, in which is being stored in the BANDANA table.
Additional info
You may execute the following SQL query to find the reindex status of the Confluence cluster.
SELECT * FROM BANDANA WHERE BANDANAKEY='reindex.status'
Cause
In this case, the status of the reindex process (in the Database) has been improperly stored - it identifies as there's an ongoing index propagation process (<stage>PROPAGATING</stage>
), even though the total propagatingProgress is 0
.
This had then resulted in an arithmetic exception when Confluence attempts to calculate the reindex progress.
Workaround
Here, we'd need to reset the reindex status from the BANDANA
table to workaround this issue. You may follow the steps below to do this:
- Scale down Confluence cluster, leaving only one node to be up and running.
- Stop this node
- Remove the
<Confluence-Home>/journal
and<Confluence-Home>/index
folders in the local home of this Node - Remove any existing index snapshots from the
<Shared-Home>/index-snapshots
folder Delete the
reindex.state
and index propagation status' records fromBANDANA
table by running the SQL queries below.
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
DELETE FROM BANDANA WHERE BANDANAKEY='reindex.status';
Start Confluence again
Once Confluence is up, the reindex should start automatically within a few minutes and progress can be monitored from atlassian-confluence-index.log. If reindex doesn't start automatically, then, please access Confluence Indexing page and re-trigger the index rebuild.
Thereindex.state
record in theBANDANA
table would be repopulated once the reindex is finished.