Uploaded image for project: 'Confluence Server'
  1. Confluence Server
  2. CONFSERVER-36348

Favourites missing after importing

    XMLWordPrintable

    Details

      Description

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? 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:

      1. Create 2 users with 2 favourite pages each
      2. Export Confluence Site
      3. 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)

      1. Open entities.xml inside the export
      2. Move object class="ConfluenceUserImpl" below the objects class="Label"
      3. Import

      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.

      Workaround 1:

      • Open entities.xml with a text editor and move all the object class="ConfluenceUserImpl" before the object class="Label" and try importing again.

      Workaround 2:
      The following steps will work for MySQL, you may need to change the syntax for other databases.

      1. Extract the favorites from the previous database with the following SQL query:
        SELECT * FROM LABEL WHERE NAME='favourite'
      2. 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.
      3. Copy old_favourite.csv to the server running your new Confluence database.
      4. 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.
      5. Let's create a temporary table:
        CREATE TABLE LABEL_OLD LIKE LABEL;
        
      6. 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

      7. Now we will move the missing labels to the correct table in Confluence:
        INSERT LABEL SELECT * FROM LABEL_OLD;
        
      8. 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);
        
      9. Clean up:
        DROP TABLE IF EXISTS test;
        
        DROP TABLE IF EXISTS LABEL_OLD;
        
      10. To make sure the indexes also contain the updated information, I suggest you to rebuild your index from scratch:
        1. 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.
        2. Remove the <confluence-home>/index directory.
        3. 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.
        4. Restart server.
        5. Now perform the manual re-indexing of your site to build a brand new index from scratch

        Attachments

          Issue Links

            Activity

              People

              Votes:
              61 Vote for this issue
              Watchers:
              64 Start watching this issue

                Dates

                Created:
                Updated:
                Last commented:
                13 weeks, 2 days ago