1 つのスペース エクスポートに複数のスペース オブジェクトが含まれ、別の Confluence インスタンスへのインポート時に失敗する
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
要約
Importing a space export file into Confluence Server or Cloud instance fails with a "Could not execute statement" or "Duplicate key" error. The source of the space export could be from either another Confluence Datacenter/Server instance or a Cloud instance.
環境
Confluence 6.x, 7.x and 8.x (and later)
診断
From within the atlassian-confluence.log file, here's an example showing a violation of the space key constraint:
com.atlassian.confluence.importexport.ImportExportException: Unable to complete import because the data does not match the constraints in the Confluence schema.
Cause: SQLServerException: Violation of UNIQUE KEY constraint 'UK_jp1ad5yufsih5r7lqrygakpug'. Cannot insert duplicate key in object 'dbo.SPACES'. The duplicate key value is (DEV).
at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:420)
at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:381)
DataCenter/Server Instances
If the space export was created from a DC/Server instance, then you can use the following query to confirm whether the DC/Server instance's database is affected by this issue:
SELECT COUNT(*)
FROM CONTENT
JOIN CONTENT xpage ON CONTENT.PAGEID = xpage.CONTENTID
WHERE CONTENT.SPACEID != xpage.SPACEID
UNION ALL
SELECT COUNT(*)
FROM CONTENT
JOIN CONTENT xpage ON CONTENT.PARENTID = xpage.CONTENTID
WHERE CONTENT.SPACEID != xpage.SPACEID
UNION ALL
SELECT COUNT(*)
FROM CONTENT
JOIN CONTENT xpage ON CONTENT.PREVVER = xpage.CONTENTID
WHERE CONTENT.SPACEID != xpage.SPACEID;
クエリでゼロのみが返される場合、ご利用のデータベースはこの問題の影響を受けていません。この場合はエクスポート/インポートの問題のトラブルシューティング支援についてアトラシアン サポートにお問い合わせください。クエリでゼロ以外の値が返される場合、ご利用のデータベースは影響を受けています。
Note that this query should be run against Confluence database from which the space was exported from, not the one you are attempting to import into.
Cloud Instances
Confluence Cloud インスタンスから取得した単一のスペースをインポートする場合、エクスポート ファイルには 1 つのスペースのオブジェクトのみが含まれる必要があります。複数のスペースのオブジェクトが含まれているかどうかを確認するには、entities.xml ファイルに対して次のコマンドを実行します。このファイルはスペースのエクスポート ファイルから抽出できます。
|
複数の結果が返される場合、エクスポート ファイルに余分なスペース オブジェクトが含まれ、Confluence インスタンスへのインポート前に修正が必要です。
原因
この問題の原因にはさまざまな問題が考えられます。
DataCenter/Server Instances
If the source of the space export was a Confluence DC/Server instance, the issue could have been caused by database inconsistencies as documented in CONFSERVER-45278 - Space import failing with the error message "could not execute statement". Another known issue relates to moving pages. This is fully described in CONFSERVER-77826 - Space id is not updated for custom objects when their containers are moved to another space which also includes queries that you can use to proactively check for and resolve instances of the problem prior to exporting a space.
Despite the previous bug was solved in some Confluence versions, there is still an unresolved bug related to this situation which points as well to database corruption/inconsistencies under: CONFSERVER-79111 - Space export may export multiple spaces
Cloud Instances
In regards to Confluence Cloud instnaces, there are several Cloud bugs which deal with the possibility that a Cloud space export may include content or space meta data from another space:
- CONFCLOUD-62976 - [Priority DoS] - Space export includes more than one space
- CONFCLOUD-64563 - Space export may export multiple spaces
- CONFDEV-62751 - A second follow-up for CONFCLOUD-64563 (Space export may export multiple spaces)
- CONFCLOUD-72415 - Space export may export multiple spaces (regression)
ソリューション
エクスポート元の Confluence データベースで見つかった問題
エクスポート元のインスタンスのデータベースがこの問題を影響を受けていることがわかったら (上記の診断を参照)、不一致を修正する必要があります。
- ご利用のデータベースの完全なバックアップを作成します。この修正を本番環境に適用する前にステージングまたはテスト環境に適用することを強く推奨します。ここでは PostgreSQL および MySQL を利用していますが、これらの SQL ステートメントはサポート対象の任意のデータベースで動作します。
Confluence を停止します。
ご利用のデータベースで次の SQL ステートメントを実行します。
ゼロ以外の値が返される場合はこの手順を繰り返してステートメントを再度実行します。ゼロのみが返される場合は問題が修正済みであるため、次の手順に進めます。
- Confluence を再起動します。
- Go to Administration > General Administration > Cache management and flush the Content Objects cache.
You can now attempt to re-export the space from your Confluence DC/Server site and import it into another Confluence site.
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
クラウド製品のスペース エクスポートで見つかった問題
この挙動を軽減するにはいくつかの方法があります。
オプション 1: SED コマンドによるリネーム
1 つめのオプションでは、entities.xml ファイルに含まれる余分な不要のスペース キーを、宛先インスタンスに存在しないスペース キーにリネームします。管理者は、宛先インスタンスに存在しないスペース キーを選択する必要があります。重複すると結果として同じ挙動になります。また、この方法では、インポートの完了後、インポートの結果発生した余分なスペースを管理者が削除する必要があります。このため、あとから削除できるよう、インポートされる余分なスペースの一覧を保持しておくことが非常に重要です。
Note that this example includes sed commands for both uppercase and lowercase values. Be sure to respect the capitalization as noted in the example to ensure non-corruption.
- 安全のため、
entities.xmlファイルのバックアップ コピーを作成します ファイルを編集し、OLDKEY と NEWKEY それぞれの値を置き換えて次のコマンドを実行します。
sed -i -e's/\[OLDKEY\]/\[NEWKEY\]/g'entities.xmlsed -i -e's/spaceKey=OLDKEY/spaceKey=NEWKEY/g'entities.xmlsed -i -e's/\[OLDKEY:/\[NEWKEY:/g'entities.xmlsed -i -e's/key=OLDKEY\]/key=NEWKEY\]/g'entities.xmlsed -i -e's/<spaceKey>OLDKEY<\/spaceKey>/<spaceKey>NEWKEY<\/spaceKey>/g'entities.xmlsed -i -e's/ri:space-key="OLDKEY"/ri:space-key="NEWKEY"/g'entities.xmlsed -i -e's/ri:space-key=OLDKEY/ri:space-key=NEWKEY/g'entities.xmlsed -i -e's/<ac:parameter ac:name="spaces">OLDKEY<\/ac:parameter>/<ac:parameter ac:name="spaces">NEWKEY<\/ac:parameter>/g'entities.xmlsed -i -e's/<ac:parameter ac:name="spaceKey">OLDKEY<\/ac:parameter>/<ac:parameter ac:name="spaceKey">NEWKEY<\/ac:parameter>/g'entities.xmlsed -i -e's/<property name="lowerDestinationSpaceKey"><!\[CDATA\[NEWKEY\]\]><\/property>/<property name="lowerDestinationSpaceKey"><!\[CDATA\[newkey\]\]><\/property>/g'entities.xmlsed -i -e's/<property name="lowerKey"><!\[CDATA\[NEWKEY\]\]><\/property>/<property name="lowerKey"><!\[CDATA\[newkey\]\]><\/property>/g'entities.xmlsed -i -e's/<property name="lowerKey"><!\[CDATA\[oldkey\]\]><\/property>/<property name="lowerKey"><!\[CDATA\[newkey\]\]><\/property>/g'entities.xmlsed -i -e's/spaceKey=OLDKEY/spaceKey=NEWKEY/g'entities.xmlsed -i -e's/spacekey=oldkey/spacekey=newkey/g'entities.xml- クラウドのエクスポートされた zip ファイルから
exportDescriptor.propertiesファイルを見つけ、スペース キーの値のリネームがそこでも行われるようにします。 - ファイルの編集が完了したらディレクトリ全体を再度圧縮します。
- インポートを再度行う前に、次のドキュメントに従ってデータベース内の余分なデータをクリーンアップするようにします。スペース インポートの失敗後、スペース データが残っているために再インポートが行えない
Option 2: Regenerate new export file from a fresh, out of the box Confluence DC/Server install
In this method, rather than clean up the export file itself, we can import the file as is into a clean Confluence instance which will ensure that a duplicate space key error will be not be thrown on import. From there, we can generate a new export of the singular intended space key which will not contain any references to the extra space.
宛先インスタンスと同じバージョンのクリーンな Confluence インスタンスを用意するようにします。
- 新しい Confluence インスタンスを立ち上げます。
- Import the Cloud export file as is and make sure it completes successfully.
Run the following SQL queries to check if the Confluence DC/Server instance is impacted as well:
SELECT COUNT(*) FROM CONTENT JOIN CONTENT xpage ON CONTENT.PAGEID = xpage.CONTENTID WHERE CONTENT.SPACEID != xpage.SPACEID UNION ALL SELECT COUNT(*) FROM CONTENT JOIN CONTENT xpage ON CONTENT.PARENTID = xpage.CONTENTID WHERE CONTENT.SPACEID != xpage.SPACEID UNION ALL SELECT COUNT(*) FROM CONTENT JOIN CONTENT xpage ON CONTENT.PREVVER = xpage.CONTENTID WHERE CONTENT.SPACEID != xpage.SPACEID;If any non-zero values are returned, follow resolution detailed under "For Issues Found within the Source Confluence Database"
- Head to Content Tools > Export of the desired space. Select XML > Full Export and create the new export file.
- 宛先インスタンスへのインポートを再度行う前に、次のドキュメントに従ってデータベース内の余分なデータをクリーンアップするようにします。スペース インポートの失敗後、スペース データが残っているために再インポートが行えない
回避策
If the previous actions did not solve the issue, you can use the workaround outlined in bug CONFSERVER-79111 - Space export may export multiple spaces
The interim workaround to ensure that the Space export contains only the desired Space is to try the following:
- Import the Space XML import into a temporary Confluence instance
- This will result in the multiple spaces imported
- From this Confluence instance, exclude the unnecessary spaces and export the desire space again out as XML
- This should result in just the Unique Space export in the newly created XML export file
- You can then take the newly created XML export file that should contain just the desire space to be imported into your desired Confluence instance