Import Fails Due to Duplicate Entry Error

お困りですか?

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

コミュニティに質問

症状

  1. You receive an error in the Confluence UI similar to this:
  2. atlassian-confluence.log に次のエラーが返される。
2012-04-13 09:44:40,457 ERROR [Long running task: Importing data] [sf.hibernate.util.JDBCExceptionReporter] logExceptions Duplicate entry 'admin' for key 'USERNAME'
 -- referer: http://localhost:8090/setup/setup-restore-local.action | url: /setup/setup-restore-local.action | userName: anonymous | action: setup-restore-local  
2012-04-13 09:44:40,473 ERROR [Long running task: Importing data] [confluence.importexport.xmlimport.BackupImporter] importEntities Cannot import the entities: 
 -- referer: http://localhost:8090/setup/setup-restore-local.action | url: /setup/setup-restore-local.action | userName: anonymous | action: setup-restore-local
com.atlassian.confluence.importexport.ImportExportException: Unable to complete import because the data does not match the constraints in the Confluence schema. Cause: MySQLIntegrityConstraintViolationException: Duplicate entry 'admin' for key 'USERNAME'
	at com.atlassian.confluence.importexport.xmlimport.DefaultXmlImporter.doImport(DefaultXmlImporter.java:67)
	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:335)
	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:303)
	...
Caused by: net.sf.hibernate.exception.ConstraintViolationException: could not insert: [com.atlassian.confluence.security.persistence.dao.hibernate.UserLoginInfo#1802246]
	at com.atlassian.confluence.importexport.xmlimport.parser.BackupParser.endElement(BackupParser.java:53)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)

診断

次のクエリを実行します。

select username from logininfo group by username having count(username) > 1;

If it returns any rows, you are affected by this issue.

原因

There are duplicate rows in the logininfo table that are blocking the restore.

ソリューション

  1. Confluence を停止します。
  2. データベースのバックアップを取得します。
  3. Run the following queries against your database:

    create temporary table deleteset as select username from logininfo group by username having count(username) > 1;
     
    delete from logininfo where username in (select username from deleteset);
    tip/resting Created with Sketch.

    We highly recommend that you run any database queries against a test instance/database before attempting to do so on your production data.

最終更新日 2018 年 11 月 12 日

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

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