Sonarqube 6.1 com.mysql.jdbc.PacketTooBigException:查询包太大

Fel*_*cke 8 sonarqube

亲爱的Sonarqube社区,

自从更新到Sonarqube 6.1后,我们在Sonarqube中收到一个错误,其中查询包太大了.我们做什么:Jenkins正在检查PHP源代码,然后SonarQube Scanner正在分析源代码并与SonarQube服务器通信.此过程失败,Jenkins中的日志输出:

org.sonarqube.ws.client.HttpException: Error 500 on http://URL-TO-SONAR/sonar/api/ce/submit?projectKey=lhind.php.PRJName&projectName=PRJName : {"errors":[{"msg":"Fail to insert data of CE task AViRLtiaB_5m8twj_1J3"}]}

  • 詹金斯版本:2.19.3
  • SonarQube版本:6.1
  • SonarQube扫描仪:2.8
  • MySQL版本:5.6.34
  • 驱动程序:MySQL Connector Java
  • 驱动程序版本:mysql-connector-java-5.1.39
  • MySQL可变"max_allowed_pa​​cket = 16M"(从4M增加)
  • MySQL Varaible"innodb_log_file_size = 128M"(从48M增加)
  • Sonar JDBC连接字符串:"
  • sonar.jdbc.url =的jdbc:mysql的:// DB-URL:3306 /声纳了useUnicode =真*的characterEncoding = UTF8&rewriteBatchedStatements =真useConfigs = maxPerformance&maxAllowedPacket = 16777216"

我们已经增加了最大数据包大小和innodb_log_file_size.使用SonarQube 6.1时,我们没有遇到与此相同数量代码的问题.

有任何想法吗?

在SonarQube中,我们在sonar.log文件中遇到以下异常:

2016.11.23 12:35:16 ERROR web[][o.s.s.w.WebServiceEngine] Fail to process request http://SONAR-URL.de:8443/sonar/api/ce/submit?projectKey=lhind.php.PRJName&projectName=PRJName java.lang.IllegalStateException: Fail to insert data of CE task AViRLtiaB_5m8twj_1J3 at org.sonar.db.ce.CeTaskInputDao.insert(CeTaskInputDao.java:56) ~[sonar-db-6.1.jar:na] (deleted because too much text ...) at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] **Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (24313938 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.** at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3671) ~[mysql-connector-java-5.1.39.jar:5.1.39] (deleted because too much text ...) at org.sonar.db.ce.CeTaskInputDao.insert(CeTaskInputDao.java:53) ~[sonar-db-6.1.jar:na] ... 34 common frames omitted

ck1*_*ck1 15

在客户端和服务器上增加MySQL中允许的最大数据包大小,以解决此问题.

服务器

有关如何在服务器上执行此操作的详细信息,请参阅此处的解决方案部分 建议将此值设置为256MB.在上面的堆栈跟踪中,数据包大小约为24MB.

https://confluence.atlassian.com/confkb/exceeds-max-allowed-packet-for-mysql-179443425.html

我喜欢上面的链接,因为它描述了如何在不停止数据库的情况下增加值,如果这对您很重要的话.

客户

在客户端上,增加maxAllowedPacketSonarQube JDBC URL中参数的值.

参考

有关更多详细信息,请参阅MySQL文档中的以下链接.

  1. http://dev.mysql.com/doc/refman/5.7/en/packet-too-large.html

客户端和服务器都有自己的max_allowed_pa​​cket变量,因此如果要处理大数据包,则必须在客户端和服务器中增加此变量.

  1. https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html

maxAllowedPacket

要发送给服务器的最大允许数据包大小.如果未设置,系统变量'max_allowed_pa​​cket'的值将用于在连接时初始化它.如果设置大于'max_allowed_pa​​cket'的值,则此值不会生效.此外,由于与属性"blobSendChunkSize"的内部依赖性,如果"useServerPrepStmts"设置为"true",则此设置的最小值为"8203".

默认值:-1

自版本:5.1.8