LexoRank balancing or manual ranking of issues fails in Jira

Symptoms

The LexoRank balancer job will be unable to complete, some issues may not be able to be ranked, or appear in the incorrect order.

When DEBUG level logging is enabled for the class com.atlassian.greenhopper.service.lexorank.balance, the following appears in the atlassian-greenhopper.log:

2014-09-10 15:03:33,052 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankBalanceOperation] Balancing rank row [type=ISSUE_RANK_ROW, oldRank=0|1026rk:, newRank=1|hzzzvz:]
2014-09-10 15:03:33,053 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankBalanceOperation] New rank[1|hzzzvz:] for issue[id=31321] for rank field[id=10890] already exists, retrying balance oepration
2014-09-10 15:03:33,054 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankBalanceOperation] Releasing lock
2014-09-10 15:03:33,054 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankBalanceOperation] balance operation timed out
2014-09-10 15:03:33,055 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankBalancer] Unlocking lexorank balance lock=com.atlassian.beehive.SingleNodeLock@66e7abb
2014-09-10 15:03:33,055 lexorank-executor-thread-0 INFO      [service.lexorank.balance.LexoRankBalancer] Balancing of 1 fields completed with 1 errors
2014-09-10 15:03:33,055 lexorank-executor-thread-0 DEBUG      [service.lexorank.balance.LexoRankScheduledBalanceHandler] Lexorank scheduled balance finished

or this error : 

2015-03-25 09:26:07,687 lexorank-executor-thread-0 WARN ServiceRunner     [service.lexorank.balance.LexoRankScheduledBalanceHandler] Balance for fieldId=10010 returned errors: Errors: {}
Error Messages: [JIRA Agile cannot execute the rank operation at this time. Other users may be ranking the issues that you are trying to rank. Please try again later.]


Diagnosis

A balance job is in progress. 

To verify the status of the balance operations in JIRA Agile:
  • If using JIRA Agile 6.7.0 or higher, access Understand the LexoRank managment page in Jira server and look at the balancing section.
  • If using JIRA 6.6.41 or higher, access <JIRA_BASE_URL>/rest/greenhopper/1.0/lexorank/balance, for example https://jira.atlassian.com/rest/greenhopper/1.0/lexorank/balance. It may help to copy/paste the results into jsonprettyprint.com as it will be easier to read them.
  • Otherwise, execute the below SQL if you are connecting Jira to PostgreSQL database:

    SELECT * FROM "AO_60DB71_LEXORANKBALANCER";
    SELECT 'ROWS_IN_BUCKET_0', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM "AO_60DB71_LEXORANK" WHERE "RANK" LIKE '0|%' GROUP BY "FIELD_ID"
    UNION
    SELECT 'ROWS_IN_BUCKET_1', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM "AO_60DB71_LEXORANK" WHERE "RANK" LIKE '1|%' GROUP BY "FIELD_ID"
    UNION
    SELECT 'ROWS_IN_BUCKET_2', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM "AO_60DB71_LEXORANK" WHERE "RANK" LIKE '2|%' GROUP BY "FIELD_ID" ORDER BY "FIELD_ID";

    For MySQL database, please execute the query below: 

    SELECT 'ROWS_IN_BUCKET_0', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM AO_60DB71_LEXORANK WHERE "RANK" LIKE '0|%' GROUP BY "FIELD_ID" UNION SELECT 'ROWS_IN_BUCKET_1', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM AO_60DB71_LEXORANK WHERE "RANK" LIKE '1|%' GROUP BY "FIELD_ID" UNION SELECT 'ROWS_IN_BUCKET_2', "FIELD_ID", coalesce(COUNT(1), 0) AS rows_in_bucket FROM AO_60DB71_LEXORANK WHERE "RANK" LIKE '2|%' GROUP BY "FIELD_ID" ORDER BY "FIELD_ID";

Either refreshing the balance endpoint, or re-running the SQL will show you the update on the balancing progress.

Cause

The ranking system uses a lexographically ordered field to determine the ranking order. If the collation includes any non-standard ordering for any alphanumeric characters, then this ranking can be ordered incorrectly when fetched from the database. This may cause JIRA Agile to attempt to insert duplicates of the same rank, or order ranks incorrectly - JSWSERVER-11178 - Unable to rank with any database collation that does not order all alphanumeric characters the same as ASCII.

Resolution

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.

The resolution differs depending on which database server is being used.

Microsoft SQL Server

  • You can set the collation just for the column affected by running the below SQL queries. You'll need to replace any occurrence of "dbo" with the schema name that the JIRA database is contained within, if you are not using the "dbo" schema.

    DROP INDEX [index_ao_60db71_lexorank_rank] ON [dbo].[AO_60DB71_LEXORANK];
    
    ALTER TABLE "AO_60DB71_LEXORANK" ALTER COLUMN RANK
                varchar(255) COLLATE Latin1_General_CI_AI NOT NULL;
    
    CREATE NONCLUSTERED INDEX [index_ao_60db71_lexorank_rank] ON [dbo].[AO_60DB71_LEXORANK]
    (
    	[RANK] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];

    (info) You may need to correct the collation for the rest of the database too, to avoid any future problems other than this one.


MySQL
  • You can set the collation just for the table affected by running the below SQL query.

    ALTER TABLE "AO_60DB71_LEXORANK" CHARACTER SET utf8 COLLATE utf8_bin;

    (info) You may need to correct the collation for the rest of the database too, to avoid any future problems other than this one.


PostgreSQL

  • PostgreSQL can't change the collation of databases that are already created, so you need to dump the database, then create it again with the correct locale, then import the dump back. The below shell commands should work, they may need username/password arguments added too:

    pg_dump jiradb > jiradb.sql
    dropdb jiradb
    createdb -E UNICODE -l C -T template0 jiradb
    psql jiradb < jiradb.sql

Last modified on Jan 22, 2025

Was this helpful?

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