JackRabbit Oak:我的应用程序需要很长时间才能启动/重新启动

Posted

技术标签:

【中文标题】JackRabbit Oak:我的应用程序需要很长时间才能启动/重新启动【英文标题】:JackRabbit Oak : my application takes long time to start/restart 【发布时间】:2020-08-29 08:36:24 【问题描述】:

我在我的 Spring Boot 项目中使用 JackRabbit 橡木实现。我的应用程序在 jcr 存储库中创建了多个节点,并集成了 PostgreSQL 数据库。 jcr 存储库中已经有大量的节点数据可用。

但是,每当我启动/重新启动我的应用程序时,我经常会出现以下日志。

"@timestamp":"2020-05-13T13:33:06.721+05:30","@version":1,"message":"Slow Query Report SQL=select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from DB_NODES where ID > ? and MODIFIED >= ? order by ID FETCH FIRST 100 ROWS ONLY; time=10963 ms;","logger_name":"org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport","thread_name":"main","level":"WARN","level_value":30000
"@timestamp":"2020-05-13T13:33:06.998+05:30","@version":1,"message":"Long running query on mango_NODES with 100 hits (limited to 100), elapsed time 11238ms (configured QUERYTIMELIMIT 10000), params minid '5:/oak:index/nodetype/:index/spr%3Atask/id1' maxid 'null' excludeKeyPatterns [] conditions [_modified >= 1584429305] limit 100. Result range: '5:/oak:index/nodetype/:index/spr%3Atask/id1'...'5:/oak:index/spr_task_jcr_created/:index/2019-05-03T04%3A31%3A29.882Z/id3'. Read 20094 chars from DATA and 0 bytes from BDATA. Check calling method.","logger_name":"org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStoreJDBC","thread_name":"main","level":"INFO","level_value":20000,"stack_trace":"java.lang.Exception: call stack\r\n\tat org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStoreJDBC.query(RDBDocumentStoreJDBC.java:522)\r\n\tat org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.internalQuery(RDBDocumentStore.java:1769)\r\n\tat org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.query(RDBDocumentStore.java:297)\r\n\tat org.apache.jackrabbit.oak.plugins.document.util.Utils$2$1.nextBatch(Utils.java:684)\r\n\tat org.apache.jackrabbit.oak.plugins.document.util.Utils$2$1.computeNext(Utils.java:668)\r\n\tat org.apache.jackrabbit.oak.plugins.document.util.Utils$2$1.computeNext(Utils.java:658)\r\n\tat com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)\r\n\tat com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)\r\n\tat com.google.common.collect.Iterators$7.computeNext(Iterators.java:650)\r\n\tat com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)\r\n\tat com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)\r\n\tat com.google.common.collect.TransformedIterator.hasNext(TransformedIterator.java:43)\r\n\tat com.google.common.collect.Iterators$7.computeNext(Iterators.java:650)\r\n\tat com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)\r\n\tat com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)\r\n\tat com.google.common.collect.Iterators$6.hasNext(Iterators.java:617)\r\n\tat org.apache.jackrabbit.oak.plugins.document.NodeDocumentSweeper.performSweep(NodeDocumentSweeper.java:152)\r\n\tat org.apache.jackrabbit.oak.plugins.document.NodeDocumentSweeper.sweep(NodeDocumentSweeper.java:122)\r\n\tat org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent.recover(LastRevRecoveryAgent.java:244)\r\n\tat org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent.recover(LastRevRecoveryAgent.java:195)\r\n\tat org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent.recoverCandidates(LastRevRecoveryAgent.java:533)\r\n\tat org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent.recover(LastRevRecoveryAgent.java:161)\r\n\tat org.apache.jackrabbit.oak.plugins.document.RecoveryHandlerImpl.recoverInternal(RecoveryHandlerImpl.java:74)\r\n\tat org.apache.jackrabbit.oak.plugins.document.RecoveryHandlerImpl.recover(RecoveryHandlerImpl.java:57)\r\n\tat org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfo.createInstance(ClusterNodeInfo.java:565)\r\n\tat org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfo.getInstance(ClusterNodeInfo.java:438)\r\n\tat org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.<init>(DocumentNodeStore.java:554)\r\n\tat org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreBuilder.build(DocumentNodeStoreBuilder.java:174)\r\n\tat com.cms.common.helper.RepositoryUtil.createRepo(RepositoryUtil.java:119)\r\n\tat com.cms.common.helper.RepositoryUtil.createRepo(RepositoryUtil.java:138)\r\n\tat com.cms.common.helper.RepositoryUtil.getRepository(RepositoryUtil.java:217)\r\n\tat com.cms.common.helper.RepositoryUtil.getSession(RepositoryUtil.java:231)\r\n\tat com.cms.services.RepositoryInitialization.createCustomNode(RepositoryInitialization.java:39)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)\r\n\tat org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)\r\n\tat org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1622)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)\r\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)\r\n\tat org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:123)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:666)\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:353)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:300)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1082)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1071)\r\n\tat com.cms.services.CMSServicesApplication.main(CMSServicesApplication.java:36)\r\n"
"@timestamp":"2020-05-13T13:33:26.999+05:30","@version":1,"message":"Sweep on cluster node [4]: 24501 nodes scanned in 7.799 min (~3141/m) - last interval 4500 nodes in 60.27 s (~4479/m)","logger_name":"org.apache.jackrabbit.oak.plugins.document.NodeDocumentSweeper","thread_name":"main","level":"INFO","level_value":20000
"@timestamp":"2020-05-13T14:24:58.069+05:30","@version":1,"message":"Recovery for cluster node [4]: 4701 nodes scanned in 60.38 s (~4671/m) - last interval 4701 nodes in 60.38 s (~4671/m)","logger_name":"org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent","thread_name":"main","level":"INFO","level_value":20000

似乎所有节点都从存储库中被扫描,因此应用程序需要很长时间才能启动。有什么方法可以快速启动应用程序,还是我需要在我的 jcr 实现中进行任何实现更改?

【问题讨论】:

【参考方案1】:

如果您在未正确关闭存储库的情况下关闭它,就会发生这种情况。

启动时,系统将扫描未完成的提交。这可能需要很长时间,具体取决于节点的数量,以及您的版本是否对https://issues.apache.org/jira/browse/OAK-8002 进行了更改。

【讨论】:

有时我的应用程序由于网络问题而自动重启,或者我们停止它以进行一些新更改的部署。在这些情况下,是否有任何方法或实现可以正确关闭存储库,或者我们只需要在我的应用程序中升级 Jack Rabbit 的最新版本? 另外我在应用程序重新启动或停止之前使用下面的代码,它似乎不起作用或者我实现了错误。 public static boolean shutDownRepo() throws RepositoryException if (repository != null) final RepositoryImpl repositoryImpl = (RepositoryImpl) repository; bapRegistration.unregister(); documentNodeStore.dispose(); repositoryImpl.shutdown(); else return false; return true; 检查关机日志。

以上是关于JackRabbit Oak:我的应用程序需要很长时间才能启动/重新启动的主要内容,如果未能解决你的问题,请参考以下文章

Apache Jackrabbit Oak 1.5.9 发布

如何通过 WebDAV 访问 Jackrabbit Oak 存储库?

Jackrabbit Oak 合并不保存更改

使用 Jackrabbit Oak 优于 MongoDB 的优势

Jackrabbit Oak:入门并通过 RMI 连接到独立存储库

Apache Jackrabbit OAK - 按节点路径跨集群分片 DocumentNodeStore