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

Revise ecosystem recommendations about CacheManager vs CacheFactory

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 7.3.5
    • Documentation - All
    • None

    Description

      The doco that tells app developers how to do caching in Confluence Server explicitly says to use CacheManager instead of CacheFactory, because of how the latter is implemented.

      The problem is that CacheManager is annotated as being for internal use only (e.g. because it has a shutdown() method that should not be invoked by apps), whereas CacheFactory was originally intended to be used by app developers and is therefore annotated with @PublicApi.

      We should resolve this contradiction to avoid (further) confusion to the ecosystem.

      N.B. it's not simply a case of switching the annotations between these two types, because:

      • there's existing code that will be made to appear like it's using the wrong API, and
      • atlassian-cache is a cross-product library, and it's entirely possible that in the other products, there's no problem with using the CacheFactory.

      And example of this in the logs is

      [INFO] [talledLocalContainer] 2022-01-14 16:12:54,388 ERROR [Caesium-1-2] [org.hibernate.internal.ExceptionMapperStandardImpl] mapManagedFlushFailure HHH000346: Error during managed flush [org.hibernate.cache.CacheException: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN)]
      [INFO] [talledLocalContainer] 2022-01-14 16:12:54,389 WARN [Caesium-1-2] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doCommit Commit failed. Rolling back. Error: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN); nested exception is net.sf.hibernate.cache.CacheException: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN)
      [INFO] [talledLocalContainer] 2022-01-14 16:12:54,389 WARN [Caesium-1-2] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:
      [INFO] [talledLocalContainer]   ->[com.atlassian.confluence.impl.schedule.caesium.SchedulerRunDetailsDao.addRunDetails]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #309102029)
      [INFO] [talledLocalContainer] 2022-01-14 16:12:54,389 ERROR [Caesium-1-2] [scheduler.caesium.impl.SchedulerQueueWorker] executeJob Unhandled exception thrown by job QueuedJob[jobId=addonHouskeeperTrigger-v2,deadline=1642137174385]
      [INFO] [talledLocalContainer] org.springframework.orm.hibernate.HibernateSystemException: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN); nested exception is net.sf.hibernate.cache.CacheException: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN)

      and in UI we see

       java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used.
      	net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1614)
      	net.sf.ehcache.CacheManager.getEhcache(CacheManager.java:1161)
      	com.atlassian.confluence.cache.ehcache.EhCacheManager.wrapCache(EhCacheManager.java:171)
      	com.atlassian.confluence.cache.ehcache.EhCacheManager.getCache(EhCacheManager.java:269)
      	com.atlassian.confluence.cache.ehcache.EhCacheManager.getCache(EhCacheManager.java:43)
      	com.atlassian.confluence.impl.cache.hibernate.HibernateClusterAwareCacheManager.getCache(HibernateClusterAwareCacheManager.java:165)
      	com.atlassian.confluence.cache.TransactionalCacheFactory.getTransactionalCache(TransactionalCacheFactory.java:118)
      	com.atlassian.confluence.cache.TransactionalCacheFactory.access$700(TransactionalCacheFactory.java:53)
      	com.atlassian.confluence.cache.TransactionalCacheFactory$TransactionalCache.getDelegate(TransactionalCacheFactory.java:309)
      	com.atlassian.confluence.cache.TransactionalCacheFactory$TransactionalCache.get(TransactionalCacheFactory.java:343)
      	com.atlassian.confluence.impl.cache.ReadThroughAtlassianCache.get(ReadThroughAtlassianCache.java:88)
      	com.atlassian.confluence.impl.cache.ReadThroughCache.get(ReadThroughCache.java:28)
      	com.atlassian.confluence.impl.bandana.ReadThroughCachingBandanaPersister.retrieve(ReadThroughCachingBandanaPersister.java:82)
      	com.atlassian.confluence.impl.bandana.ReadThroughCachingBandanaPersister.retrieve(ReadThroughCachingBandanaPersister.java:75)
      ...

      Attachments

        Activity

          People

            Unassigned Unassigned
            aswan@atlassian.com Andrew S
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: