我是靠谱客的博主 笑点低灰狼,最近开发中收集的这篇文章主要介绍[Bugfix]Error opening new searcher. exceeded limit of maxWarmingSearchers=2, try again later.,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

    at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:577)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:241)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:230)
    at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.request(ConcurrentUpdateSolrClient.java:354)
    at org.apache.solr.client.solrj.SolrClient.request(SolrClient.java:1219)
    at org.apache.solr.update.SolrCmdDistributor.doRequest(SolrCmdDistributor.java:299)
    at org.apache.solr.update.SolrCmdDistributor.access$000(SolrCmdDistributor.java:53)
    at org.apache.solr.update.SolrCmdDistributor$1.call(SolrCmdDistributor.java:286)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:231)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

问题:solr 提交报错
场景:客户端使用spring-data-solr save()方法提交数据
查看源码

@Override
    public <S extends T> S save(S entity) {
        Assert.notNull(entity, "Cannot save 'null' entity.");
        registerTransactionSynchronisationIfSynchronisationActive();
        this.solrOperations.saveBean(entity);
        //这步commit了
        commitIfTransactionSynchronisationIsInactive();
        return entity;
    }



private void commitIfTransactionSynchronisationIsInactive() {
        if (!TransactionSynchronizationManager.isSynchronizationActive()) {
            this.solrOperations.commit();
        }
    }
 public static boolean isSynchronizationActive() {
        return synchronizations.get() != null;
    }

    public static void initSynchronization() throws IllegalStateException {
        if(isSynchronizationActive()) {
            throw new IllegalStateException("Cannot activate transaction synchronization - already active");
        } else {
            logger.trace("Initializing transaction synchronization");
            synchronizations.set(new LinkedHashSet());
        }
    }

结论spring-data-solr在save的时候 如果没有设置事务管理 会直接执行solrClient.commit()方式(硬提交)
解决方案:
方案1:设置事务
方案2:弃用spring-data-solr 改为源生solrj
直接调用solrClient.addBeans(args);
(只add 不提交,提交的动作由solr服务端决定)
配置solrconfig.xml

 <!-- softAutoCommit is like autoCommit except it causes a
         'soft' commit which only ensures that changes are visible
         but does not ensure that data is synced to disk.  This is
         faster and more near-realtime friendly than a hard commit.
      2分钟提交一次

    -->

 <autoSoftCommit>
      <maxTime>${solr.autoSoftCommit.maxTime:120000}</maxTime>
    </autoSoftCommit>

PS:因为没用过spring-data-solr 且项目紧 采用了方案2
有用过spring-data-solr的同学 说下怎么配置事务呢 听说要设置data-source?

最后

以上就是笑点低灰狼为你收集整理的[Bugfix]Error opening new searcher. exceeded limit of maxWarmingSearchers=2, try again later.的全部内容,希望文章能够帮你解决[Bugfix]Error opening new searcher. exceeded limit of maxWarmingSearchers=2, try again later.所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(33)

评论列表共有 0 条评论

立即
投稿
返回
顶部