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

MacroMigrationService.migrateAll migrates only the first ten pages

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: High High
    • None
    • 5.5, 5.6.6
    • None

      MacroMigrationService has a few issues:

      In order to find out which pages to migrate, it creates the following search:

      new ContentSearch(getAllLegacyMacrosQuery(), null, null, filter)
      

      This ends up calling the following constructor (after a few calls to super and this):

          public AbstractSearch(SearchQuery query, SearchSort sort, SearchFilter searchFilter, ResultFilter resultFilter) {
              this(query, sort, searchFilter, 0, SearchConstants.DEFAULT_LIMIT, resultFilter);
          }
      

      Where SearchConstants.DEFAULT_LIMIT is 10 (obviously).

      So only the first ten pages found are actually checked for migration.

      If we set this limit to Integer.MAX_VALUE in the debugger, we hit the next problem:

          @Deprecated
          public SearcherWithTokenAction(Query query, Filter filter, Sort sort, int startOffset, int limit, Set<String> requestedFields, LuceneResultFilter luceneResultFilter)
          {
              this.query = query;
              this.filter = filter;
              this.sort = sort;
              this.startOffset = Math.min(startOffset, SearchConstants.MAX_START_OFFSET);
              this.limit = Math.min(limit, SearchConstants.MAX_LIMIT);
              this.requestedFields = requestedFields;
              this.luceneResultFilter = luceneResultFilter;
          }
      

      Where SearchConstants.MAX_LIMIT is 500.

      This would not be a problem if the client of the above search would be pagination-aware, but behold! - it isn't. It just happily copies the first 10 resp. 500 search results into a SearchResultsBatchWorkSource (which in, itself, is completely unaware of pagination that is forced upon it by SearchConstants.MAX_LIMIT).
      This might just be triggered by the fact that searchResults.getAll() does NOT (as the name would suggest), return all search results, but only the ones that are on the first page (i.e. max 500). Bummer.

            [CONFSERVER-36581] MacroMigrationService.migrateAll migrates only the first ten pages

            ekurimoto that's correct, the problem is in the retrieving of content for bulk migration of old data, not inserting individual wiki markup macros into the editor

            Steve Lancashire (Inactive) added a comment - ekurimoto that's correct, the problem is in the retrieving of content for bulk migration of old data, not inserting individual wiki markup macros into the editor

            Hi Steve,

            Let me ask you some question.
            Does it issue when you import or paste old data include macros from older version like 3.x?
            If so, it's not a problem as long as you start with 5.5, 5.6 on your system right?

            regards,

            Eiichi Kurimoto added a comment - Hi Steve, Let me ask you some question. Does it issue when you import or paste old data include macros from older version like 3.x? If so, it's not a problem as long as you start with 5.5, 5.6 on your system right? regards,

            This issue exists, and was introduced in 5.5 with changes to AbstractSearch to have a default limit. The patch returns the performance profile to something equivalent to the previous functionality.

            Steve Lancashire (Inactive) added a comment - This issue exists, and was introduced in 5.5 with changes to AbstractSearch to have a default limit. The patch returns the performance profile to something equivalent to the previous functionality.

            Martin Sander added a comment - - edited

            Crude patch that seems to work as a workaround.

            Note: It is quick and dirty, obviously you would want to make SearchResultsBatchWorkSource paging-aware instead.
            But I wanted this with minimal change - we have enough RAM, we will only do this once..

            Martin Sander added a comment - - edited Crude patch that seems to work as a workaround. Note: It is quick and dirty, obviously you would want to make SearchResultsBatchWorkSource paging-aware instead. But I wanted this with minimal change - we have enough RAM, we will only do this once..

              Unassigned Unassigned
              101ec24b4e2e Martin Sander
              Affected customers:
              2 This affects my team
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: