如何正确关闭Jackrabbit+MongoDB服务器?

问题描述 投票:0回答:1

我们有一个用Java编写的应用程序(Spring Boot),使用Jackrabbit与MongoDB,这是MongoDB的配置,我们有两个令人沮丧的问题与MongoDB(或也许jackrabbit)。

@Configuration
@Profile("production")
public class MongoRepositoryInitializer {
    @Value("${oak.mongo.db}")
    private String mongoDbName;

    @Value("${oak.mongo.uri}")
    private String mongoUri;

    @Bean
    public Repository repository(DocumentNodeStore documentNodeStore) {
        return new Jcr(new Oak(documentNodeStore)).createRepository();
    }

    @Bean
    public MongoClient mongoClient() {
        new MongoClientOptions.Builder()
                .maxConnectionIdleTime(30000)
                .build();
        return new MongoClient(new MongoClientURI("mongodb://" + mongoUri));
    }

    @Bean
    public MongoDatabase mongoDatabase(MongoClient mongoClient) {
        return mongoClient.getDatabase(mongoDbName);
    }

    @Bean
    public MongoBlobStore mongoBlobStore(MongoClient mongoClient) {
        return new MongoBlobStore(mongoClient.getDatabase(mongoDbName));
    }

    @Bean
    public DocumentNodeStore documentNodeStore(MongoClient mongoClient, MongoBlobStore mongoBlobStore) {
        return MongoDocumentNodeStoreBuilder
                .newMongoDocumentNodeStoreBuilder().setMongoDB(mongoClient, mongoDbName, 16)
                .setBlobStore(mongoBlobStore)
                .build();
    }
}

我们在MongoDB上有两个令人沮丧的问题(也许是jackrabbit). 第一个问题是,当我们启动应用程序一段时间后,我们得到了以下错误:

org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore
 - Background operation failed: org.apache.jackrabbit.oak.plug
 ins.document.DocumentStoreException: This oak instance failed to update
 the
 lease in time and can therefore no longer access this DocumentNodeStore.
 org.apache.jackrabbit.oak.plugins.document.DocumentStoreException: This
 oak
 instance failed to update the lease in time and can therefore no longer
 access this DocumentNodeStore.

我们只能通过重启MongoDB来解决这个错误.

第二个问题是,在重启应用程序后(没有重启MongoDB),我们得到了以下日志,我们必须等待一段时间(大约100秒)才能完成应用程序的启动。

2020-05-03 16:12:44.059  INFO 13854 --- [  restartedMain] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[192.168.0.176:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2020-05-03 16:12:44.176  INFO 13854 --- [168.0.176:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:1, serverValue:36}] to 192.168.0.176:27017
2020-05-03 16:12:44.182  INFO 13854 --- [  restartedMain] org.mongodb.driver.cluster               : Cluster description not yet available. Waiting for 30000 ms before timing out
2020-05-03 16:12:44.183  INFO 13854 --- [168.0.176:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=192.168.0.176:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 5]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=5367075}
2020-05-03 16:12:44.205  INFO 13854 --- [  restartedMain] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:2, serverValue:37}] to 192.168.0.176:27017
2020-05-03 16:12:44.462  INFO 13854 --- [  restartedMain] o.a.j.o.p.d.mongo.MongoDocumentStore     : Connected to MongoDB 4.2.5 with maxReplicationLagMillis 21600000, maxDeltaForModTimeIdxSecs 60, disableIndexHint false, clientSessionSupported false, clientSessionInUse true, serverStatus WriteConcern{w=null, wTimeout=null ms, fsync=null, journal=null
2020-05-03 16:12:44.489  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Found an existing possibly active cluster node info (12) for this instance: mac:525400bb0ae9//home/mehrdad/epic/parent, will try use it.
2020-05-03 16:12:44.489  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 106s left
2020-05-03 16:12:49.492  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 101s left
2020-05-03 16:12:54.495  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 96s left
2020-05-03 16:12:59.498  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 91s left
2020-05-03 16:13:04.500  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 86s left
2020-05-03 16:13:09.502  INFO 13854 --- [  restartedMain] o.a.j.o.p.document.ClusterNodeInfo       : Waiting for cluster node 12's lease to expire: 81s left

看来这些问题都是相关的。

我在网上搜了一下,有人说这是因为jackrabbit服务器关机不好,但我找不到正确的关机方法。 如果有什么建议,我将感激不尽

mongodb jackrabbit
1个回答
0
投票

对于第一个问题,你应该检查系统日志,可能Mongo实例超过120s没有响应?

对于第二个问题:你需要确保在关闭时,DocumentStore的dispose方法被调用。

© www.soinside.com 2019 - 2024. All rights reserved.