gretard / sonar-sql-plugin

SQL language (T-SQL, MySQL, Snowflake, Vertica and PostgreSQL dialects) plugin for SonarQube

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.OutOfMemoryError: Java heap space

kumarmohe opened this issue · comments

Hi,

We have recently installed this plug-in on our SonarQube Sever Community EditionVersion 7.9.2 (build 30863). When I tried to Code analysis of our Visual Studio DacPac project that has many .sql files (TSQL), its ending up with the errors shown in the attached file.

Sonar-SQL-Code-Analysis.txt

I tried setting the environment variable "SONAR_RUNNER_OPTS" in the build server as "-Xmx3062m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m" and restarted it, but no use. The error still remains.

Prepare Analysis Task in TFS CI/CD Build Pipeline is set as "Use Standalone Scanner". However, it works fine when I use "Integrate with MSBuild" option. But Sonar documentation says, for doing this kind (SQL Code Analysis, Angular Code Analysis) of code analysis, it should be set as "Use Standalone Scanner".

Could you have a look and suggest any possible solution please?

Thanks,
Mohan

@gretard I just wanted to bring to your notice.

Hi @kumarmohe - did you manage to solve this issue? :)

Sorry @gretard . I was away from this for last a couple of days, so late response. This issue still exists. I tried increasing the heap memory, but no use. Our sonar server is running in Docker Container. Our Admin guys are trying to increase the memory for the container. I don't have direct access to the Sonar Qube Sever. Waiting for their response.

Almost all our .sql files are giving this issue. I am not sure anything wrong in those files.

Hi,

Maybe this will help :) You need to specify environment variable named SONAR_SCANNER_OPTS instead of SONAR_RUNNER_OPTS.

I just tried to run commands as this on Windows:

set SONAR_SCANNER_OPTS=-Xmx3062m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m
sonar-scanner.bat 

And saw in the log file options being picked as this in the output:

OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was remov
ed in 8.0
INFO: Scanner configuration file: E:\darbai\sonar\sonar-scanner-cli-4.4.0.2170-w
indows\sonar-scanner-4.4.0.2170-windows\bin..\conf\sonar-scanner.properties
INFO: Project root configuration file: E:\darbai\sonar\samples\sql-server-sample
s-master\samples\databases\adventure-works\data-warehouse-install-script\sonar-p
roject.properties
INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 8.1 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx3062m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSiz
e=128m

Please try this and check in the output if you see those options being picked :)

I did as you suggested. Though I don't see "SONAR_SCANNER_OPTS" option in the log. But most of the Memory Heap issues are gone except for one file.


2020-08-12T18:54:41.3490614Z 14:54:41.331 INFO: SonarScanner 4.4.0.2170
2020-08-12T18:54:41.3491013Z 14:54:41.347 INFO: Java 1.8.0_261 Oracle Corporation (32-bit)
2020-08-12T18:54:41.3491226Z 14:54:41.347 INFO: Windows Server 2016 10.0 x86
2020-08-12T18:54:41.5132970Z 14:54:41.503 DEBUG: keyStore is :
2020-08-12T18:54:41.5133558Z 14:54:41.503 DEBUG: keyStore type is : jks
2020-08-12T18:54:41.5134036Z 14:54:41.503 DEBUG: keyStore provider is :
2020-08-12T18:54:41.5134226Z 14:54:41.503 DEBUG: init keystore

Now I see new set of errors as shown below.

2020-08-12T18:57:33.2410732Z 14:57:33.228 WARN: Unexpected exception while analyzing file: SQLDacPac/dbo/Stored Procedures/GetBudgetIncomeStatementActualsStats.sql
2020-08-12T18:57:33.2423645Z java.lang.ArrayIndexOutOfBoundsException: 1
2020-08-12T18:57:33.2760704Z at org.sonar.plugins.sql.sensors.sqlcheck.SQLCheckIssuesReader.read(SQLCheckIssuesReader.java:62)
2020-08-12T18:57:33.2761185Z at org.sonar.plugins.sql.sensors.SqlCheckSensor.execute(SqlCheckSensor.java:99)
2020-08-12T18:57:33.2761387Z at org.sonar.plugins.sql.sensors.SqlCheckSensor.access$000(SqlCheckSensor.java:23)
2020-08-12T18:57:33.2761600Z at org.sonar.plugins.sql.sensors.SqlCheckSensor$1.run(SqlCheckSensor.java:62)
2020-08-12T18:57:33.2761825Z at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
2020-08-12T18:57:33.2762464Z at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
2020-08-12T18:57:33.2762670Z at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
2020-08-12T18:57:33.2762851Z at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
2020-08-12T18:57:33.2763076Z at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
2020-08-12T18:57:33.2763199Z
2020-08-12T18:57:33.2763420Z 14:57:33.260 DEBUG: Running SQLCheck with [c:\program files\sql-check\sqlcheck.exe, -f, D:<Removed>_work\5\s\SQLDacPac\dbo\Stored Procedures\GetBudgetScenarioCopyExportData.sql, -v]
2020-08-12T18:57:34.2901597Z 14:57:34.275 WARN: Unexpected exception while analyzing file: SQLDacPac/dbo/Stored Procedures/GetBudgetIncomeStatementScenarios.sql
2020-08-12T18:57:34.2903279Z java.lang.ArrayIndexOutOfBoundsException: 1
2020-08-12T18:57:34.2906429Z at org.sonar.plugins.sql.sensors.sqlcheck.SQLCheckIssuesReader.read(SQLCheckIssuesReader.java:62)
2020-08-12T18:57:34.2910381Z at org.sonar.plugins.sql.sensors.SqlCheckSensor.execute(SqlCheckSensor.java:99)
2020-08-12T18:57:34.2984594Z at org.sonar.plugins.sql.sensors.SqlCheckSensor.access$000(SqlCheckSensor.java:23)
2020-08-12T18:57:34.2985751Z at org.sonar.plugins.sql.sensors.SqlCheckSensor$1.run(SqlCheckSensor.java:62)
2020-08-12T18:57:34.2986141Z at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
2020-08-12T18:57:34.2986445Z at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
2020-08-12T18:57:34.2986690Z at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
2020-08-12T18:57:34.2986947Z at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
2020-08-12T18:57:34.2987184Z at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
2020-08-12T18:57:34.2987614Z

I have attached complete log below.

Thanks for your support.

Thanks,
Mohan

Sonar-SQL-Code-Analysis.txt

Hi, I found an issue with SQLCheck sensor. Please try the latest version https://github.com/gretard/sonar-sql-plugin/releases/tag/1.1.0

Sure. Will try it. Thanks.

We have deployed the new version. Testing is going on. I will update once its done.