Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-59196

Updating a page via REST API causes 501 error after upgrading to Confluence 7+ due to contentproperties table modification

    XMLWordPrintable

Details

    Description

      Atlassian Update - Feb 2020

      Hi All,

      We have prepared a fix for this issue and we have made this fix available in the Confluence EAP release 7.4.0-m05 and in Confluence 7.3.3. 

      We went through all cases reported for this issue (at least all we were able to reproduce), and fixed it by introducing a new recovery mechanism for unreconciled page updates. Recovery should happen transparently for all callers, so the API should behave as it used to before 7.0 (but now without danger of losing unpublished changes). Please give it a try and provide feedback.

      On a side note please keep in mind, that in rare cases ExternalChangesException can still happen in the case where content update fails for some reason, so please don't forget to handle it appropriately. The fix also includes changes to solve the problem with visibility of ExternalChangesException class in the plugins and changes to the confusing exception message.

      Lastly, if you need more fine access over the content reconciliation process, please consider using PageUpdateService. Its prepare() method can be used to ensure that content and draft are synchronized and are ready for updates. Methods of this service can be called within as well as outside of the active database transaction.

      Thank you for your patience and we look forward to receiving your feedback on this fix.

      Regards,

      The Confluence Team

      Issue Summary

      Updating a page via REST API causes 501 error after upgrading to Confluence 7+ the first time it's called.
      The propertyname = 'sync-rev-source' or equivalent from the table contentproperties is replaced with the value restored in all rows.
      Viewing the page or making the call again will succeed as it sets the 'propertyname' back to 'synchrony' or 'synchrony-ack' as expected.

      Steps to Reproduce

      1. Install Confluence 6.15.9 and make sure the Demonstration Space was created (You can create other pages for testing)
      2. Run the following query:
        select * from contentproperties where propertyname = 'sync-rev-source';
        1. Make sure that none of the properties is set to 'restored'. They should be either 'synchrony-ack' or 'synchrony' as described on How do drafts work.
      1. Upgrade Confluence to 7.1.0
      2. Make sure not to view any of the pages
      3. Execute the same query again. You should be able to see that every property was set to 'restored':
        +--------------+-----------------+---------------+-----------+-----------+-------------+
        | propertyid   | propertyname    | stringval     | longval   | dateval   | contentid   |
        |--------------+-----------------+---------------+-----------+-----------+-------------|
        | 131237       | sync-rev-source | restored      | <null>    | <null>    | 65590       |
        | 131328       | sync-rev-source | restored      | <null>    | <null>    | 65628       |
        | 131291       | sync-rev-source | restored      | <null>    | <null>    | 65607       |
        
      1. Pick one of the rows with 'restored' value and it's contentId and execute following REST
        PUT request: {base-url}
        /rest/api/content/
        
        {contentId} with this json body:
        {"id":{contentId}
        ,"type":"page",
        "title":"new page updated","space":
        
        {"key":"key"}
        ,"body":{"storage":{"value":
        "<p>This is the updated text for the new page updated</p>","representation":"storage"}},"version":
        
        {"number":1}
        }}
        
      1. Notice the following response:
        {
        "statusCode": 501,
        "message": "Unable to save changes to unreconciled page ContentId
        
        {id=65607}
        . Refreshing the page should fix this.",
        "reason": "Not Implemented"
        }

      Expected Results

      The page is updated accordingly.

      Actual Results

      A 501 error is received and the page is not updated.

      Workaround

      Making the call again or viewing the page will allow it to work as it sets the stringval in contentproperties back to synchrony or synchrony-ack.

      • 7.0.2 - Disabling/enabling collaborative editing clears the 'sync-rev-source' values and allows the calls to work. This method does not work for 7.1.0.

      Notes

      Known to cause issues with some plugins like K15 Scroll Versions when trying to publish pages, as the same error is thrown when using the JAVA API methods saveContentEntity() and saveNewVersion() from the com.atlassian.confluence.pages.DefaultPageManager class.
      Calling again the methods does not always work in setting the stringval in contentproperties back from "restored" as opposed to the REST API so that workaround for plugins is not reliable.

      Attachments

        Issue Links

          Activity

            People

              mfedoryshyn Maksym Fedoryshyh
              dmark@atlassian.com Danny (Inactive)
              Votes:
              142 Vote for this issue
              Watchers:
              114 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: