Confluence 7.16 prompts LuceneContentIndexFlusher scheduled job failed every time after a page is created

Hey guys,

Recently our team encountered an error which is very odd, every time when a content(page/space, etc) is created, our add-ons’ Extractor2 implementation has been invoked and doing some indexing job to Confluence’s search index. From Confluence 7.16 onwards, we start to get this error:

runJob Scheduled job LuceneContentIndexFlusher#LuceneContentIndexFlusher completed unsuccessfully with response JobRunnerResponse[runOutcome=FAILED,message='UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only']

In the Extractor2 implementation, we called a activeObjects.create() to create some data for our app use, this operation can not be done due to the transaction is on read-only mode, and because of that it has been marked as rollback. We wrapped the activeObjects.create() in a transaction like this:

return activeObjects.executeInTransaction(new TransactionCallback<E>() {
            @Override
            public E doInTransaction() {
                return activeObjects.create(entityClass, params);
            }
        });

The error will be retained doesn’t matter we use activeObjects directly or TransactionTemplate. Here is the full error log:

2022-03-18 16:55:38,977 ERROR [Caesium-1-4] [engine.jdbc.spi.SqlExceptionHelper] logExceptions ERROR: current transaction is aborted, commands ignored until end of transaction block
2022-03-18 16:55:38,981 WARN [Caesium-1-4] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:
  ->[com.atlassian.confluence.search.lucene.LuceneIncrementalIndexManager.flushQueue]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly (Session #395956775)
2022-03-18 16:55:38,982 WARN [Caesium-1-4] [confluence.impl.search.IndexFlushScheduler] lambda$new$1 Failed to flush index queue LuceneContentIndexFlusher, retry in 10s
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:870)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:707)
	at sun.reflect.GeneratedMethodAccessor199.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
	at com.sun.proxy.$Proxy77.commit(Unknown Source)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy189.flushQueue(Unknown Source)
	at com.atlassian.confluence.impl.search.IndexFlushScheduler.lambda$new$1(IndexFlushScheduler.java:122)
	at com.atlassian.confluence.impl.schedule.caesium.JobRunnerWrapper.doRunJob(JobRunnerWrapper.java:117)
	at com.atlassian.confluence.impl.schedule.caesium.JobRunnerWrapper.lambda$runJob$0(JobRunnerWrapper.java:87)
	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:84)
	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:68)
	at com.atlassian.confluence.impl.schedule.caesium.JobRunnerWrapper.runJob(JobRunnerWrapper.java:87)
	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134)
	at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:106)
	at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:90)
	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:435)
	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeLocalJob(CaesiumSchedulerService.java:402)
	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:380)
	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
	at java.lang.Thread.run(Thread.java:748)
2022-03-18 16:55:38,982 WARN [Caesium-1-4] [impl.schedule.caesium.JobRunnerWrapper] runJob Scheduled job LuceneContentIndexFlusher#LuceneContentIndexFlusher completed unsuccessfully with response JobRunnerResponse[runOutcome=FAILED,message='UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only']

The implementation works fine until we installed the add-ons in Confluence 7.16. And this only happened when users are using PostgreSQL database.
Any advice would be appreciated!

P.S: We using active objects version 4.0.2