[Bugfix]Error opening new searcher. exceeded limit of maxWarmingSearchers=2, try again later.

来源:互联网 发布:淘宝内裤真人秀在哪看 编辑:程序博客网 时间:2024/06/09 20:47
    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?

0 0