sonar ERROR Timeout trying to lock table “PROJECT_

2019-09-08 01:06发布

问题:

I'm using SonarQube 5.1 (using default Database H2) with Gradle 2.3/4.

In SonarQube, I'm using a trial version for Views portfolio management plugin which (combines SonarQube project's metrics across as a component and lets you create views like all projects under a given team, department, manager, all app projects, all service projects etc.

sonarRunner task is working successfully in Gradle. Once the analysis is done, I have to run another command to pick the latest analysis for "Views Portfolio plugin" and the command I run every 2 minutes (using a Jenkins job) is: sonar-runner views

sonarRunner task worked fine for few days but today I'm seeing an error in Jenkins.

Any ideas what I'm missing here?.

PS: It works automatically after few minutes as I'm running the job every 2 minutes.

00:00:05.987 23:29:38.207 INFO  - Load module settings
00:00:06.382 23:29:38.603 INFO  - Load rules
00:00:07.456 23:29:39.677 INFO  - Index files
00:00:07.463 23:29:39.683 INFO  - 0 files indexed
00:00:07.913 23:29:40.134 INFO  - Sensor ViewsSensor
00:00:09.935 23:29:42.155 WARN  - SQL Error: 50200, SQLState: HYT00
00:00:09.935 23:29:42.156 ERROR - Timeout trying to lock table "PROJECT_MEASURES"; SQL statement:
00:00:09.935 select measuremod0_.id as id5_, measuremod0_.alert_status as alert2_5_, measuremod0_.alert_text as alert3_5_, measuremod0_.characteristic_id as characte4_5_, measuremod0_.measure_data as measure5_5_, measuremod0_.description as descript6_5_, measuremod0_.metric_id as metric7_5_, measuremod0_.person_id as person8_5_, measuremod0_.project_id as project9_5_, measuremod0_.rule_id as rule10_5_, measuremod0_.rule_priority as rule11_5_, measuremod0_.snapshot_id as snapshot12_5_, measuremod0_.tendency as tendency5_, measuremod0_.text_value as text14_5_, measuremod0_.url as url5_, measuremod0_.value as value5_, measuremod0_.variation_value_1 as variation17_5_, measuremod0_.variation_value_2 as variation18_5_, measuremod0_.variation_value_3 as variation19_5_, measuremod0_.variation_value_4 as variation20_5_, measuremod0_.variation_value_5 as variation21_5_ from project_measures measuremod0_ where measuremod0_.snapshot_id=? and (measuremod0_.person_id is null) [50200-176]
00:00:09.972 INFO: ------------------------------------------------------------------------
00:00:09.972 INFO: EXECUTION FAILURE
00:00:09.972 INFO: ------------------------------------------------------------------------
00:00:09.973 Total time: 9.802s
00:00:10.234 Final Memory: 43M/1448M
00:00:10.235 INFO: ------------------------------------------------------------------------
00:00:10.236 ERROR: Error during Sonar runner execution
00:00:10.237 ERROR: Unable to execute Sonar
00:00:10.237 ERROR: Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
00:00:10.237 ERROR: Caused by: could not execute query
00:00:10.238 ERROR: Caused by: Timeout trying to lock table "PROJECT_MEASURES"; SQL statement:
00:00:10.238 select measuremod0_.id as id5_, measuremod0_.alert_status as alert2_5_, measuremod0_.alert_text as alert3_5_, measuremod0_.characteristic_id as characte4_5_, measuremod0_.measure_data as measure5_5_, measuremod0_.description as descript6_5_, measuremod0_.metric_id as metric7_5_, measuremod0_.person_id as person8_5_, measuremod0_.project_id as project9_5_, measuremod0_.rule_id as rule10_5_, measuremod0_.rule_priority as rule11_5_, measuremod0_.snapshot_id as snapshot12_5_, measuremod0_.tendency as tendency5_, measuremod0_.text_value as text14_5_, measuremod0_.url as url5_, measuremod0_.value as value5_, measuremod0_.variation_value_1 as variation17_5_, measuremod0_.variation_value_2 as variation18_5_, measuremod0_.variation_value_3 as variation19_5_, measuremod0_.variation_value_4 as variation20_5_, measuremod0_.variation_value_5 as variation21_5_ from project_measures measuremod0_ where measuremod0_.snapshot_id=? and (measuremod0_.person_id is null) [50200-176]
00:00:10.238 ERROR: 
00:00:10.239 ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
00:00:10.239 ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
00:00:10.271 Build step 'Execute shell' marked build as failure

For this project, when I try to see the project itself in SonarQube, I see the following line with yellow background:

No analysis has been performed since creation. The only available section is the configuration.

All other projects show valid SonarQube dashboard page.

回答1:

Found the solution to the first issue. I was doing a POC on using Views Portfolio plugin and it requires to regularly run "sonar-runner views" command to publish/fetch new data for Views.

There was a Jenkins job which was running just "sonar-runner views" every 2 minutes and at the same time, other Jenkins job (for a project) was doing sonarRunner (analysis) then this error was coming.

To solve it, I changed the job which was running sonar-runner views command to NOT to run if any of the other Jenkins jobs were in progress (retrict checkbox in Job's configuration).

Now I'm not getting that SQL error.


I'm still looking at why even when sonarRunner task (Gradle) is successful, it is not generating a particular project in SonarQube home page. i.e. I'm getting:

No analysis has been performed since creation. The only available section is the configuration.

PS: All other project's sonarRunner task shows the same successful run and they are visible in SonarQube.

Found the solution for the second issue i.e
to resolve the "No analysis has been performed since creation. The only available section is the configuration".

I found the few days back I updated few plugins (i.e. sonar-api pluging etc etc from X.X to X.Y version) but they all were sitting in PENDING installation state i.e. after I downloaded them, I didn't restart sonar instance to pick them.

I just restarted sonar instance and the error is gone, everything is working now.