Full reindex fails with message Duplicate keys mapped in Jira

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

    

要約

When performing a full reindex in Jira, it fails with several WARN messages about "Duplicate keys mapped" like this below:

2021-03-12 15:59:56,965-0300 IssueIndexer:thread-1 WARN admin 959x1839x1 1wtf9jg 0:0:0:0:0:0:0:1 /secure/admin/jira/IndexReIndex!reindex.jspa [c.a.jira.index.AccumulatingResultBuilder] java.lang.IllegalStateException: Duplicate keys mapped to com.atlassian.jira.issue.customfields.vdi.CustomFieldPrefetchedData@6934d589 / com.atlassian.jira.issue.customfields.vdi.CustomFieldPrefetchedData@5c73dbed for custom field id customfield_10221

And later the reindex failure message:

2021-03-12 15:59:57,136-0300 JiraTaskExecutionThread-3 ERROR admin 959x1839x1 1wtf9jg 0:0:0:0:0:0:0:1 /secure/admin/jira/IndexReIndex!reindex.jspa [c.a.j.util.index.CompositeIndexLifecycleManager] Reindex All FAILED. ...


環境

All versions of Jira 8.

診断

1) Look for the reindex all failure in the logs:

cat atlassian-jira.log | grep -i "reindex all failed"


2) Look for "Duplicate keys mapped" messages and their respective customfields:

cat atlassian-jira.log | grep "Duplicate keys mapped to" | egrep -o "customfield_.*" | sort | uniq -c

This should output each customfield and the number of messages for each:

Example output
3025 customfield_10250
 150 customfield_10251


3) Check if there are any fields that have values in both the label and customfieldvalue tables:

select distinct f.id, f.cfname
from label l
join customfieldvalue v on v.customfield = l.fieldid
join customfield f on f.id = v.customfield
where l.fieldid is not null and v.stringvalue is not null
and f.customfieldtypekey = 'com.atlassian.jira.plugin.system.customfieldtypes:labels';

Confirm their ids are the same that showed up on the logs (in step #2).

原因

There's a label-type customfield with values stored in the customfieldvalue table instead of the label table only.

This scenario shouldn't exist and Jira's reindex doesn't completely succeeds, leaving the index incomplete or in a non-reliable state (eg. filter results show different values than the issue screen).

根本原因

We don't know yet how label-type fields could have values stored in the customfieldvalue table. Maybe it's the work of 3rd party apps or custom scripts running in Jira (through Script-enabling apps) — or a direct database insert.


ソリューション

We should remove the invalid entries from the customfieldvalue for those label-type fields table and perform a full reindex again:

delete from customfieldvalue where customfield in (10250, 10251); -- example Ids

データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。



Last modified on Mar 15, 2021

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.