Status: Short Term Backlog (View Workflow)
Severity 3 - Minor
NOTE: This bug report is for Confluence Cloud. Using Confluence Server? See the corresponding bug report.
The import process misplaces Favourites on the database and they might disappear for one user and appear under another user.
The problem happens randomly when migrating Confluence because it depends on the order of the objects in the entities.xml file of the export. It affects Confluence Cloud and Server.
Steps to reproduce:
- Create 2 users with 2 favourite pages each
- Export Confluence Site
- Import Site
Expected: each of the 2 users have 2 favourites
Result: one user will have all favourites and the other none.
If it didn't reproduce: (how to manually make it fail)
- Open entities.xml inside the export
- Move object class="ConfluenceUserImpl" below the objects class="Label"
Confluence logs show the following message:
2015-05-20 17:44:51.109723500 2015-05-20 17:44:51,105 WARN [Long running task: Importing data] [atlassian.confluence.importexport.DefaultImmutableImportProcessorSummary] newInstance Cannot add old key = class=class com.atlassian.confluence.labels.Label,id=819202,<null> and new key = class=class com.atlassian.confluence.labels.Label,id=6422529,<null> to the summary. One of them is a duplicate.
where 819202 is the id of the label that doesn't get inserted.
- Open entities.xml with a text editor and move all the object class="ConfluenceUserImpl" before the object class="Label" and try importing again.
The following steps will work for MySQL, you may need to change the syntax for other databases.
- Extract the favorites from the previous database with the following SQL query:
SELECT * FROM LABEL WHERE NAME='favourite'
- As we want to transfer that data to a different database, I suggest you to create a CSV file with the output of the previous command which we will call old_favourite.csv.
- Copy old_favourite.csv to the server running your new Confluence database.
- Shutdown your current instance of Confluence to avoid data inconsistencies while we modify the database.
Please make sure you backup your data before you do any changes so we can roll back in case it is needed.
- Let's create a temporary table:
CREATE TABLE LABEL_OLD LIKE LABEL;
- Let's now dump the content of the CSV file into the temporary table. In PostgreSQL you should be able to do this with the following command:
load data local infile '/full/path/to/old_favourite.csv' into table tblUniq fields terminated by ',' enclosed by '"' lines terminated by '\n' (uniqName, uniqCity, uniqComments)
You may need to modify the query depending on the format of the CSV file generated in step #2
- Now we will move the missing labels to the correct table in Confluence:
INSERT LABEL SELECT * FROM LABEL_OLD;
- Let's update the table CONTENT_LABEL to make sure it contains the correct information. We will need to run the following queries separately in MySQL:
CREATE TABLE test (id BIGINT);
INSERT INTO test SELECT CL.ID FROM CONTENT_LABEL CL INNER JOIN LABEL L ON CL.LABELID = L.LABELID WHERE L.NAME = 'favourite' AND CL.OWNER <> L.OWNER;
UPDATE CONTENT_LABEL CL JOIN LABEL L ON CL.OWNER = L.OWNER SET CL.LABELID = L.LABELID WHERE CL.ID IN (SELECT id FROM test);
- Clean up:
DROP TABLE IF EXISTS test;
DROP TABLE IF EXISTS LABEL_OLD;
- To make sure the indexes also contain the updated information, I suggest you to rebuild your index from scratch:
- Make a backup of your <confluence-home>/index/plugin directory if it exists. This is where the Usage Tracking plugin stores it's index for the usage statistics and it cannot be rebuilt.
- Remove the <confluence-home>/index directory.
- If in step #9.1, you have the <confluence-home>/index/plugin directory, create the <confluence-home>/index directory and copy in the backup of <confluence-home>/index/plugin directory made in step 2.
- Restart server.
- Now perform the manual re-indexing of your site to build a brand new index from scratch