Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonarqube 6.1 com.mysql.jdbc.PacketTooBigException: Packet for query is too large

Tags:

sonarqube

Dear Sonarqube community,

since update to Sonarqube 6.1 we are getting an error within Sonarqube where a Packet for query is too large. What we do: Jenkins is checking out PHP source code, then SonarQube Scanner is analyzing the source code and communicates with the SonarQube server. This process is failing with the log output in 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"}]}

  • Jenkins Version: 2.19.3
  • SonarQube Version: 6.1
  • SonarQube Scanner: 2.8
  • MySQL Version: 5.6.34
  • Driver: MySQL Connector Java
  • Driver Version: mysql-connector-java-5.1.39
  • MySQL Varaible "max_allowed_packet = 16M" (increased from 4M)
  • MySQL Varaible "innodb_log_file_size = 128M" (increased from 48M)
  • Sonar JDBC connection string: "
  • sonar.jdbc.url=jdbc:mysql://DB-URL:3306/sonar?useUnicode=true&*characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&maxAllowedPacket=16777216"

We alread increased the max packet size and innodb_log_file_size. We DO NOT had this problem with the same amount of code with SonarQube 6.1.

Any ideas?

In SonarQube we got the following exception in sonar.log file:

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

like image 275
Felix Beucke Avatar asked Nov 23 '16 13:11

Felix Beucke


2 Answers

Increase the maximum allowed packet size in MySQL on both the client and server to work around this problem.

Server

See the Resolution section here for details about how to do this on the server. The recommendation there is to set this value to 256MB. In the stacktrace above, the packet size is around 24MB.

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

I like the link above because it describes how to increase the value without stopping the database, if that's important to you.

Client

On the client, increase the value of the maxAllowedPacket parameter in the SonarQube JDBC URL.

Reference

For more details, see the following links in the MySQL documentation.

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

Both the client and the server have their own max_allowed_packet variable, so if you want to handle big packets, you must increase this variable both in the client and in the server.

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

maxAllowedPacket

Maximum allowed packet size to send to server. If not set, the value of system variable 'max_allowed_packet' will be used to initialize this upon connecting. This value will not take effect if set larger than the value of 'max_allowed_packet'. Also, due to an internal dependency with the property "blobSendChunkSize", this setting has a minimum value of "8203" if "useServerPrepStmts" is set to "true".

Default: -1

Since version: 5.1.8

like image 80
ck1 Avatar answered Sep 26 '22 06:09

ck1


I had a same issue however, we had a limitation where we could not change the MySQL server configuration (max_allowed_packet)

I was able to get this working by changing the Client side jdbc URL configurations -> leaving the server config as is.

Note that we have to use 'useServerPrepStmts=true' here.

jdbc:mysql://[dbhost]:[dbport]?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf8&useServerPrepStmts=true&maxAllowedPacket=20000000&useSSL=false

Check the mysql connector config reference here

There is one more post on SO that talks abt Client side change in detail - check here

Hope this helps!

like image 33
Rishi Avatar answered Sep 23 '22 06:09

Rishi