Confluence 6 針對 key "cp_" 或 "cps_" 的 "Duplicate Entry" 問題解決

若是你遇到了下面的錯誤信息,例如:sql

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 '1475804-Edit' for key 'cps_unique_type'

上面表示在 XML 的備份文件中恢復的數據庫沒有正確的權限,一般是由於使用了第三方的插件的緣由。這個問題在 Confluence 3.5.2 的後續版本中已經修復了,請參考 CONF-22123 中的說明。若是你的版本已是新的版本了,你的導出文件可能須要手動進行修改來刪除掉重複權限實例,或者整個記錄都須要被刪除。下面的 SQL 能夠被用來找到這個記錄。數據庫

SELECT * FROM CONTENT_PERM WHERE USERNAME IS NULL AND GROUPNAME IS NULL ;
 
FROM CONTENT_PERM cp
WHERE cp.USERNAME IS NOT NULL AND cp.GROUPNAME IS NOT NULL ;
 
SELECT cps1.ID, cps1.CONTENT_ID, cps1.CONT_PERM_TYPE FROM CONTENT_PERM_SET cps1, CONTENT_PERM_SET cps2
WHERE cps1.ID <> cps2.ID AND
 
( SELECT scps.ID FROM CONTENT_PERM_SET scps WHERE scps.CONTENT_ID = cps.CONTENT_ID AND scps.CONT_PERM_TYPE = cp.CP_TYPE) AS suggested_cps_id
FROM CONTENT_PERM cp, CONTENT_PERM_SET cps
WHERE cp.CPS_ID = cps.ID AND
 
FROM CONTENT_PERM cp1, CONTENT_PERM_SET cps1, CONTENT_PERM cp2, CONTENT_PERM_SET cps2
WHERE
cp1.ID <> cp2.ID AND
 
FROM CONTENT_PERM cp1, CONTENT_PERM_SET cps1, CONTENT_PERM cp2, CONTENT_PERM_SET cps2
WHERE
cp1.ID <> cp2.ID AND
 
SELECT * FROM CONTENT_PERM_SET
WHERE ID NOT IN ( SELECT DISTINCT CPS_ID FROM CONTENT_PERM);

刪除全部找到的記錄,而後嘗試從新導出。eclipse

 

https://www.cwiki.us/display/CONFLUENCEWIKI/Troubleshooting+XML+backups+that+fail+on+restorespa

相關文章
相關標籤/搜索