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

Page Index Macro max page threshold does not prevent macro from indexing beyond that limit

XMLWordPrintable

      Steps to reproduce

      1. Create space with at least 30000 pages. Problem will be easier to observe with more pages
      2. Add a page with the index macro
      3. Save

      Expected behavior

      Page renders quickly with the macro indicating that page index cannot be displayed due to space containing more than 5000 pages

      Actual behavior

      The page takes a long time to render. It will eventually show the expected message above, OR it will show a 120 second macro timeout given enough pages (which occurred at ~130k pages in my testing).

      Analysis

      Through SQL logging we can see that Confluence does indeed issue a query to count pages in the space, and the results are correctly received. The below is pulled from a test Confluence 6.6.2 instance where the space has 129077 pages.

      2018-04-25 17:03:01,229 DEBUG [http-nio-5662-exec-6] [org.hibernate.SQL] logStatement select cast(count(*) as int8) as col_0_0_ from CONTENT page0_ cross join SPACES space1_ where page0_.CONTENTTYPE='PAGE' and page0_.SPACEID=space1_.SPACEID and space1_.LOWERSPACEKEY=? and (page0_.PREVVER is null) and page0_.CONTENT_STATUS='current'
      2018-04-25 17:03:01,230 TRACE [http-nio-5662-exec-6] [type.descriptor.sql.BasicBinder] bind binding parameter [1] as [VARCHAR] - [myspacekey]
      
      2018-04-25 17:03:01,351 TRACE [http-nio-5662-exec-6] [type.descriptor.sql.BasicExtractor] extract extracted value ([col_0_0_] : [BIGINT]) - [129077]
      

      However, it continues to fetch all the pages anyway in the next query:

      2018-04-25 17:03:01,352 DEBUG [http-nio-5662-exec-6] [org.hibernate.SQL] logStatement select page0_.CONTENTID as CONTENTI1_12_0_, contentper1_.ID as ID1_15_1_, page0_.HIBERNATEVERSION as HIBERNAT2_12_0_, page0_.TITLE as TITLE4_12_0_, page0_.LOWERTITLE as LOWERTIT5_12_0_, page0_.VERSION as VERSION6_12_0_, page0_.CREATOR as CREATOR7_12_0_, page0_.CREATIONDATE as CREATION8_12_0_, page0_.LASTMODIFIER as LASTMODI9_12_0_, page0_.LASTMODDATE as LASTMOD10_12_0_, page0_.VERSIONCOMMENT as VERSION11_12_0_, page0_.PREVVER as PREVVER12_12_0_, page0_.CONTENT_STATUS as CONTENT13_12_0_, page0_.PAGEID as PAGEID14_12_0_, page0_.SPACEID as SPACEID15_12_0_, page0_.CHILD_POSITION as CHILD_P16_12_0_, page0_.PARENTID as PARENTI17_12_0_, contentper1_.CONT_PERM_TYPE as CONT_PER2_15_1_, contentper1_.CONTENT_ID as CONTENT_3_15_1_, contentper1_.CREATIONDATE as CREATION4_15_1_, contentper1_.LASTMODDATE as LASTMODD5_15_1_, contentper1_.CONTENT_ID as CONTENT_3_15_0__, contentper1_.ID as ID1_15_0__ from CONTENT page0_ left outer join CONTENT_PERM_SET contentper1_ on page0_.CONTENTID=contentper1_.CONTENT_ID where page0_.CONTENTTYPE='PAGE' and page0_.SPACEID=? and (page0_.PREVVER is null) and page0_.CONTENT_STATUS='current'
      
      Example thread dump
      "http-nio-5662-exec-4" #177 daemon prio=5 os_prio=31 tid=0x00007fb6993a6000 nid=0x17c03 runnable [0x000070000b76b000]
         java.lang.Thread.State: RUNNABLE
      	at java.lang.System.identityHashCode(Native Method)
      	at org.hibernate.internal.util.collections.IdentityMap$IdentityKey.hashCode(IdentityMap.java:226)
      	at java.util.HashMap.hash(HashMap.java:338)
      	at java.util.HashMap.put(HashMap.java:611)
      	at org.hibernate.internal.util.collections.IdentityMap.put(IdentityMap.java:94)
      	at org.hibernate.engine.internal.StatefulPersistenceContext.addCollection(StatefulPersistenceContext.java:854)
      	at org.hibernate.engine.internal.StatefulPersistenceContext.addUninitializedCollection(StatefulPersistenceContext.java:825)
      	at org.hibernate.type.CollectionType.getCollection(CollectionType.java:768)
      	at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:461)
      	at org.hibernate.type.CollectionType.resolve(CollectionType.java:454)
      	at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:165)
      	at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
      	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1146)
      	at org.hibernate.loader.Loader.processResultSet(Loader.java:1005)
      	at org.hibernate.loader.Loader.doQuery(Loader.java:943)
      	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
      	at org.hibernate.loader.Loader.doList(Loader.java:2615)
      	at org.hibernate.loader.Loader.doList(Loader.java:2598)
      	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430)
      	at org.hibernate.loader.Loader.list(Loader.java:2425)
      	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:370)
      	at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
      	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1481)
      	at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1441)
      	at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1410)
      	at com.atlassian.confluence.pages.persistence.dao.hibernate.HibernatePageDao.getPagesWithPermissions(HibernatePageDao.java:181)
      	at com.atlassian.confluence.pages.persistence.dao.hibernate.CachingPageDao.getPagesWithPermissions(CachingPageDao.java:352)
      	at com.atlassian.confluence.pages.DefaultPageManager.getPagesWithPermissions(DefaultPageManager.java:1822)
      ...
      	at com.atlassian.confluence.plugins.macros.advanced.IndexMacro.fetchPages(IndexMacro.java:126)
      	at com.atlassian.confluence.plugins.macros.advanced.IndexMacro.getHtml(IndexMacro.java:75)
      	at com.atlassian.confluence.renderer.radeox.macros.AbstractHtmlGeneratingMacro.execute(AbstractHtmlGeneratingMacro.java:45)
      	at com.atlassian.renderer.macro.RadeoxCompatibilityMacro.execute(RadeoxCompatibilityMacro.java:149)
      	at com.atlassian.confluence.renderer.v2.macros.RadeoxCompatibilityMacro.execute(RadeoxCompatibilityMacro.java:46)
      	at com.atlassian.renderer.v2.macro.ResourceAwareMacroDecorator.execute(ResourceAwareMacroDecorator.java:51)
      	at com.atlassian.confluence.macro.V2CompatibilityMacro.execute(V2CompatibilityMacro.java:36)
      	at com.atlassian.confluence.macro.LazyLoadingMacroWrapper.execute(LazyLoadingMacroWrapper.java:24)
      ...
      

              epyshnograev Efim (Inactive)
              nlopez@atlassian.com Nancy Lopez
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: