solr 4 线上服务,解决慢查询导入问题。Query execution was interrupted


问题:

mysql 数据库设置了慢查询断开功能,查询慢,直接把客户端杀掉。

solr链接mysql 进行数据库导入。结果报错Query execution was interrupted

at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
                                        at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:253)
                                        at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:210)
                                        at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:38)
                                        at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
                                        at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
                                        at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:243)
                                        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:465)
                                        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:404)
                                        ... 5 more
                                      Caused by: java.sql.SQLException: Query execution was interrupted
                                        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
                                        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
                                        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
                                        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
                                        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
                                        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
                                        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2637)
                                        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2566)
                                        at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:782)
                                        at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:625)
                                        at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:246)
                                        ... 12 more

查询了下官方的文档:


解决:

修改配置文件 :
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/dbname" user="db_username" password="db_password"
batchSize="10"
/>

设置batchsize = 10 也就是每次查询 10 条记录,然后创建索引。mysql的数据量在3000万左右。

上一篇:微软CEO:聊天机器人将颠覆人们对计算机的使用


下一篇:国内首款敏捷数据管理平台ADM发布