Viewing Content Indexing page results in ArithmeticException or NullPointerException

Still need help?

The Atlassian Community is here for you.

Ask the community

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'
Sample results returned...
testdb=> SELECT * FROM BANDANA WHERE BANDANAKEY='reindex.status';
 bandanaid | bandanacontext |   bandanakey   |                                bandanavalue                                
-----------+----------------+----------------+----------------------------------------------------------------------------
 796164098 | _GLOBAL        | reindex.status | <com.atlassian.confluence.index.status.ReIndexJob>                        +
           |                |                |   <id>cb5f35bf-db0b-4532-8c27-228b72c2e515</id>                           +
           |                |                |   <startTime>2021-10-06T14:54:15.400125Z</startTime>                      +
           |                |                |   <stage>PROPAGATING</stage>                                              +
           |                |                |   <acknowledged>false</acknowledged>                                      +
           |                |                |   <rebuildingProgress>                                                    +
           |                |                |     <total>3301489</total>                                                +
           |                |                |     <processed>3301489</processed>                                        +
           |                |                |   </rebuildingProgress>                                                   +
           |                |                |   <lastRebuildingUpdate>2021-10-06T18:57:51.842634Z</lastRebuildingUpdate>+
           |                |                |   <propagatingProgress>                                                   +
           |                |                |     <total>0</total>                                                      +
           |                |                |     <processed>8</processed>                                              +
           |                |                |   </propagatingProgress>                                                  +
           |                |                |   <nodeStatuses class="list">                                             +
           |                |                |     <com.atlassian.confluence.index.status.ReIndexNodeStatus>             +
           |                |                |       <nodeId>d64ead2c</nodeId>                                           +
           |                |                |       <state>REBUILD_COMPLETE</state>                                     +
           |                |                |     </com.atlassian.confluence.index.status.ReIndexNodeStatus>            +
           |                |                |     <com.atlassian.confluence.index.status.ReIndexNodeStatus>             +
           |                |                |       <nodeId>d64ec2ba</nodeId>                                           +
           |                |                |       <state>PROPAGATION_COMPLETE</state>                                 +
           |                |                |     </com.atlassian.confluence.index.status.ReIndexNodeStatus>            +
           |                |                |     <com.atlassian.confluence.index.status.ReIndexNodeStatus>             +
           |                |                |       <nodeId>d64eb777</nodeId>                                           +
           |                |                |       <state>PROPAGATION_COMPLETE</state>                                 +
           |                |                |     </com.atlassian.confluence.index.status.ReIndexNodeStatus>            +
           |                |                |     <com.atlassian.confluence.index.status.ReIndexNodeStatus>             +
           |                |                |       <nodeId>d64e9fda</nodeId>                                           +
           |                |                |       <state>PROPAGATION_COMPLETE</state>                                 +
           |                |                |     </com.atlassian.confluence.index.status.ReIndexNodeStatus>            +
           |                |                |     <com.atlassian.confluence.index.status.ReIndexNodeStatus>             +
           |                |                |       <nodeId>d64ea73d</nodeId>                                           +
           |                |                |       <state>PROPAGATION_COMPLETE</state>                                 +
           |                |                |     </com.atlassian.confluence.index.status.ReIndexNodeStatus>            +
           |                |                |   </nodeStatuses>                                                         +
           |                |                | </com.atlassian.confluence.index.status.ReIndexJob>
(1 row)

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:

  1. Scale down Confluence cluster, leaving only one node to be up and running.
  2. Stop this node
  3. Remove the <Confluence-Home>/journal  and <Confluence-Home>/index folders in the local home of this Node
  4. Remove any existing index snapshots from the <Shared-Home>/index-snapshots folder
  5. Delete the reindex.state and index propagation status' records from BANDANA 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';
  6. Start Confluence again

  7. 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.
    (info) The reindex.state record in the BANDANA table would be repopulated once the reindex is finished.


Description
Product

Last modified on May 30, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.