solr DataImportHandler 报错 Communications link failure
来源:互联网 发布:四川广电网络 业务 编辑:程序博客网 时间:2024/05/02 00:57
使用solr好几个月了,今天终于出了一个相当棘手的问题,花了本尊一天时间来解决,最终搞定。但在解决的过程中,各种百度谷歌,99%的答案并不能解决问题。本尊都已经下载源码准备打持久战。最终的神来一笔让这个问题迎刃而解,特此分享。
solr做full-import时,DIH连接MYSQL读取数据建立索引,数据量有100w行,并且有子entity
<dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://123.123.123.123:3333/discuz" batchSize="-1" user="root" password="123" /> <document> <entity name="xm_common_member" query="select * from xm_common_member"> <field column="uid" name="id"/> <entity name="xm_common_member_profile" query="select * from xm_common_member_profile where uid=${xm_common_member.uid}"> <field column="field4" name="livingcity"/> </entity> <entity name="xm_common_member_status" query="select lastarea from xm_common_member_status where uid=${xm_common_member.uid}"/> </entity> </document></dataConfig>
建索引的过程需要2个小时。问题出在建立索引结束时,ResultSet调用close()方法会抛异常。
这里就很奇怪了。java的基本库方法抛异常,查看日志并没有oom日志,说明不是内存溢出。异常堆栈信息也不能说清楚问题。
对于Communications link failure,网上的文章都在说连接池未设置超时而Mysql超时,但我手动写了连接读取MYSQL的java程序,其中sleep 20分钟,都不见报一样的错误。所以问题根源还在solr代码建索引的处理上。
stack overflow上有一篇文章, http://stackoverflow.com/questions/17137626/solr-dataimport-from-mysql-dies-when-mysq-query-limit-is-removed
使用这种方式
select * from xm_common_member limit 0, 10000限制了每次读取的条数,然后在增加多个root的entity,分别limit 10000,10000, limit 20000,10000……
经过测试,这样确实可以某种程度上解决问题。但是limit的条数必须在5000条以下,超过了依然报相同的错误。但数据量已经达到100w,这么写配置要写死,扩展性也基本为0。
绝望之际,打算看看java的基础类库com.mysql.jdbc.mysqlio,找找源码报错中的信息,意外发现了这个文章http://stackoverflow.com/questions/4436997/communications-link-failure-due-to-java-io-eofexception
在连接url后加一个autoReconnect=true。
很显然,报错是因为连接断掉了,然后加一个自动连接就对了。
至此,问题得到解决,但是是在原因不清楚的情况下解决。
代码界总是不乏类似案例,比如重装系统,重启系统。。。
如果真想追根究底,那就要慢慢阅读源码从长计议咯。
现在的配置如下
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://baidu.com:330/discuz?autoReconnect=true" batchSize="-1" user="root" password="4444" />
- solr DataImportHandler 报错 Communications link failure
- Communications link failure报错的处理
- 连接数据库报错 Communications link failure
- 程序报错CommunicationsException:Communications link failure
- Mysql报错:communications link failure
- Mysql报错!Communications link failure due to underlying exception
- mycat 时不时报 Communications link failure
- Communications link failure
- Communications link failure
- mysql: Communications link failure
- Communications link failure
- Communications Link failure
- Communications link failure
- CommunicationsException: Communications link failure
- Communications link failure
- mysql Communications link failure
- Communications link failure
- Communications link failure
- 运维笔记34 (lnmp+heartbeat高可用集群,drbd共享存储+Discuz论坛应用实战)
- 几种机器学习框架的对比和选择
- QT+opencv视频采集和存储Demo
- java对象内存管理的简单认识!
- 使用git bash上传代码到Github并忽略文件
- solr DataImportHandler 报错 Communications link failure
- Unity Shader-后处理:简单均值模糊
- Pandas 文本数据方法 partition( )
- C语言的点
- 【SQL】ROWNUM和ROWID
- Hadoop学习笔记2、集群网络规划及SSH免密码登录
- 我的科研生活2017-3-21
- kernel: TCP: time wait bucket table overflow的问题剖析及解决方法
- 关于mysql的事物