Performing rollback. Transactions: ->[com.atlassian.confluence.pages.DefaultPageManager.saveContentEntity Message when removing macro from page with groovy script

Hi all,

I hope someone could advise regarding the following issue we experiencing.

When running the following script using Script Runner from Confluence (console script), we get the following:

[hibernate.ConfluenceHibernateTransactionManager]: Performing rollback. Transactions: ->[com.atlassian.confluence.pages.DefaultPageManager.saveContentEntity]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #864697185)2020-09-08

14:23:04,557 DEBUG [indigo.ReplaceTargeted]: Exception = The version of the object to be saved was more than the previous version!null

Someone known what that means? The script is working as expected, so it looks, but we would like to be sure we do not miss anything else due to these exceptions.

def startTag = ‘<ac:structured-macro ac:name=“targeted-search-field” ac:schema-version=“1”’
def endTag = ‘</ac:parameter></ac:structured-macro>’
def brikitReplaceParam = ‘<ac:parameter ac:name=“replace-default”>true</ac:parameter>’

while(content && content.contains(brikitReplaceParam)){
     totalMacroToRemove = null
        boolean needToRemove = false 
        def indexOfStart = 0
        while(indexOfStart < content.size() && indexOfStart >= 0){
                log.debug("totalMacroToRemove" + totalMacroToRemove)
                log.debug("indexOfStart " + indexOfStart)
                log.debug("content.size: " + content.size())
                //Configure the macro to remove
                String macroToRemove = StringUtils.substringBetween (content.substring(indexOfStart), startTag, endTag)
                totalMacroToRemove = startTag + macroToRemove + endTag
                //log.debug("This is the macro to be removed: " + totalMacroToRemove)
                    log.debug("totalMacroToRemove" + totalMacroToRemove)
                    log.debug("totalMacroToRemove.contains(brikitReplaceParam: " + totalMacroToRemove.contains(brikitReplaceParam))

                        log.debug("Found relevanr size befor change: " + content.size())
                        content = (content - totalMacroToRemove)
                        log.debug("Macro was removed from page: " + page)
                        needToRemove = true
                              log.debug("content.indexOf(startTag, indexOfStart): "+ content.indexOf(startTag, indexOfStart))
                     if(content.indexOf(startTag, indexOfStart) > 0){//look for the second macro
                         indexOfStart = content.indexOf(startTag, indexOfStart) + totalMacroToRemove.size()
                         log.debug("indexOfStart after new: " + indexOfStart)

					totalMacroToRemove = null
                    indexOfStart = content.size()
                log.debug("indexOfStart end: " + indexOfStart)
               	totalMacroToRemove = null

            log.debug("needToRemove: " + needToRemove)
                content = (content - totalMacroToRemove)
                log.debug("Macro was removed from page: " + page)
                page.setBodyAsString(content)  //set the new content
                page.setVersionComment("Brikit Targeted Search Removal Job")
                pageManager.saveContentEntity(page, oldVersion, DefaultSaveContext.SUPPRESS_NOTIFICATIONS)//save the page
                //log.debug("NEW CONTENT: " + content)
        }//second while

}//first while


log.debug(“macroToRemove is null for this page” + page)
//}//End Pages

//}//End spaces`

Thank you in advance,