XWiki Platform
  1. XWiki Platform
  2. XWIKI-14626

Data loss when using the refactoring script service to move a space under some conditions

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 9.3.1
    • Fix Version/s: None
    • Component/s: Refactoring
    • Labels:
      None
    • Environment:
      Original problem was encoutered on my wiki on myxwiki.org, running XWiki 9.3.1, and then reproduced locally on 9.7-SNAPSHOT
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      To reproduce:

      • Create 3 pages with the following hierarchy: A > B > C
      • Then on another page, put the following content and execute it (the idea is to move all pages from space A.B into space A):
        {{velocity}}
        #set ($source = $services.model.resolveSpace('A.B'))
        #set ($destination = $services.model.resolveSpace('A'))
        $services.refactoring.move($source, $destination).join()
        {{/velocity}}
        

      Expected:

      • All pages located under space A.B are moved to space A.

      Results:

      • The pages B and C have not been moved
      • The pages B and C have had their content wiped out and a redirect xobject put in them that redirects to themselves (and thus viewing them fails with an infinite loop detected by the browser)
      • The pages are also in the recycle bin but displayed twice (see screenshot)
      • You cannot restore them because they still exist so you can force a delete by going to http://localhost:8080/xwiki/bin/delete/A/B/C/ for example. Then if you restore the bottom-most version you should get back your content, at least on XWiki 9.7-SNAPSHOT. When I tried on myxwiki.org which is running 9.3.1, I got a stack trace:
        Detailed information:
            Error number 0 in 3: Exception while hibernate execute
        com.xpn.xwiki.XWikiException: Error number 0 in 3: Exception while hibernate execute
        	at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1340)
        	at com.xpn.xwiki.store.XWikiHibernateBaseStore.executeRead(XWikiHibernateBaseStore.java:1401)
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore.getDeletedDocument(XWikiHibernateRecycleBinStore.java:251)
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore.getDeletedDocument(XWikiHibernateRecycleBinStore.java:245)
        	at com.xpn.xwiki.XWiki.getDeletedDocument(XWiki.java:1932)
        	at com.xpn.xwiki.web.UndeleteAction.action(UndeleteAction.java:62)
        	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:446)
        	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:210)
        	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
        	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
        	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
        	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:112)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:127)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202)
        	at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:180)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:134)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:164)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        	at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:193)
        	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        	at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.NullPointerException
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore.resolveDeletedDocumentContent(XWikiHibernateRecycleBinStore.java:160)
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore.access$200(XWikiHibernateRecycleBinStore.java:57)
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore$2.doInHibernate(XWikiHibernateRecycleBinStore.java:260)
        	at com.xpn.xwiki.store.XWikiHibernateRecycleBinStore$2.doInHibernate(XWikiHibernateRecycleBinStore.java:252)
        	at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1334)
        	... 57 more
        

      The job log contains:

      Starting job of type [refactoring/move] with identifier [refactoring/move/1503044812735-307]
      Document [Home » A » B » C » WebHome] has been deleted with all its translations.
      Document [Home » A » B » C » WebHome] has been copied to [Home » A » B » C » WebHome].
      Document [Home » A » B » C » WebHome] has been updated.
      Updating the back-links for document [Home » A » B » C » WebHome] in wiki [xwiki].
      No relative links to update in [Home » A » B » C » WebHome].
      Document [Home » A » B » C » WebHome] has been deleted with all its translations.
      Created automatic redirect from [Home » A » B » C » WebHome] to [Home » A » B » C » WebHome].
      Document [Home » A » B » WebHome] has been deleted with all its translations.
      Document [Home » A » B » WebHome] has been copied to [Home » A » B » WebHome].
      Document [Home » A » B » WebHome] has been updated.
      Updating the back-links for document [Home » A » B » WebHome] in wiki [xwiki].
      No relative links to update in [Home » A » B » WebHome].
      Document [Home » A » B » WebHome] has been deleted with all its translations.
      Created automatic redirect from [Home » A » B » WebHome] to [Home » A » B » WebHome].
      Finished job of type [refactoring/move] with identifier [refactoring/move/1503044812735-307]
      

      (retrieved using http://extensions.xwiki.org/xwiki/bin/view/Extension/Refactoring%20Module#HDebugging)

        Activity

        Hide
        Vincent Massol added a comment -

        This raises some questions:

        • Why it failed?
        • Why the 2 deletions?
        • Why the job log starts with "Document [Home » A » B » C » WebHome] has been deleted with all its translations."?
        Show
        Vincent Massol added a comment - This raises some questions: Why it failed? Why the 2 deletions? Why the job log starts with "Document [Home » A » B » C » WebHome] has been deleted with all its translations."?

          People

          • Assignee:
            Unassigned
            Reporter:
            Vincent Massol
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: