SonarQube 分析读取超时 [英] Read timed out on SonarQube analysis

查看:51
本文介绍了SonarQube 分析读取超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们之前讨论过现在关闭的问题 SonarQube 用户邮件列表.

We previously discussed the problem on the now closed SonarQube Users mailing list.

通过优化Postgre DB换了大约半周,问题又解决了,问题又出现了.

The problem was solved by exchanging the for about half a week by optimizing the Postgre DB, then the problem reoccured.

我们使用 Jenkins 1.612 和 SonarQube Jenkins 插件 2.2.1,Sonar 5.1 使用 Postgre 9.1 数据库.

We are using Jenkins 1.612 using the SonarQube Jenkins Plugin 2.2.1, Sonar 5.1 using a Postgre 9.1 database.

  • 我们正在使用大量遗留代码运行大约 20 个 JAVA 项目/分支,并且有大约 120 万个 LOC 和 13 万个问题.
  • 大约有 30 个 JAVA 项目模块项目具有 1k-20k LOC 和少于 2k 个问题.
  • 大约有 50 个自定义 JAVA 项目的 LOC 少于 200k 且问题少于 10k.
  • 我们的项目是用 JAVA (6/7) 编写的,并使用 ANT 50% 或 Gradle 50% 作为构建工具.

现在我们又遇到了这个错误:

Now we are getting this error again:

Gestartet durch vorgelagertes Projekt "Project__Branch__ant__dbTest", Build 86
originally caused by:
 Gestartet durch vorgelagertes Projekt "Project__Branch__ant__build", Build 101
 originally caused by:
  Build wurde durch eine SCM-Änderung ausgelöst.
Baue auf Slave SonarQube (Sonar-Analyse) in Arbeitsbereich D:Jenkins (prod-test)workspaceProject__Branch__ant__sonar
Restoring workspace from build #101 of project Project__Branch__ant__build
[Project__Branch__ant__sonar] $ "D:Jenkins (prod-test)	oolshudson.plugins.sonar.SonarRunnerInstallationsonar-runner-2.4insonar-runner.bat" -e -Dsonar.jdbc.url=jdbc:postgresql://localhost:5432/postgres ******** ******** -Dsonar.host.url=http://sonarqube:9000 ******** ******** "-Dsonar.projectBaseDir=D:Jenkins (prod-test)workspaceProject__Branch__ant__sonar" -Dsonar.branch=Branch
D:Jenkins (prod-test)	oolshudson.plugins.sonar.SonarRunnerInstallationsonar-runner-2.4
SonarQube Runner 2.4
Java 1.7.0_45 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
SONAR_RUNNER_OPTS=-Xmx2048m -XX:MaxPermSize=256m
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: D:Jenkins (prod-test)	oolshudson.plugins.sonar.SonarRunnerInstallationsonar-runner-2.4confsonar-runner.properties
INFO: Project configuration file: D:Jenkins (prod-test)workspaceProject__Branch__ant__sonarsonar-project.properties
INFO: Default locale: "de_DE", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Work directory: D:Jenkins (prod-test)workspaceProject__Branch__ant__sonar.sonar
INFO: SonarQube Server 5.1
02:22:57.131 INFO  - Load global repositories
02:22:59.624 INFO  - Load global repositories (done) | time=2533ms
02:22:59.642 INFO  - Server id: 20150601083800
02:22:59.650 INFO  - User cache: C:.sonarcache
02:22:59.768 INFO  - Install plugins
02:23:05.720 INFO  - Install JDBC driver
02:23:05.781 INFO  - Create JDBC datasource for jdbc:postgresql://localhost:5432/postgres
02:23:14.096 INFO  - Initializing Hibernate
02:23:28.270 INFO  - Load project repositories
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:05.593s
Final Memory: 38M/269M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Unable to request: /batch/project?key=Project%3ABranch&preview=false
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:109)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:99)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:87)
    at org.sonar.batch.repository.DefaultProjectRepositoriesLoader.load(DefaultProjectRepositoriesLoader.java:55)
    at org.sonar.batch.repository.ProjectRepositoriesProvider.provide(ProjectRepositoriesProvider.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
    at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
    at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
    at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
    at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
    at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:698)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:631)
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:698)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:677)
    at org.sonar.api.platform.ComponentContainer.getComponentByType(ComponentContainer.java:209)
    at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1673)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1671)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1244)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:298)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:255)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:105)
    ... 59 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2678)
    at java.net.URLConnection.getContentEncoding(URLConnection.java:533)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:296)
    ... 61 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone SonarQube Analysis' marked build as failure
Sending e-mails to: ****@****.**
Notifying upstream projects of job completion
Finished: FAILURE

希望您能帮助找到解决此问题的方法.谢谢.

I hope you may help finding a solution for this problem. Thx.

可操作性恢复:如果从 Jenkins 触发,找到解决方法.

Operability restored: Found a workaround if triggered from Jenkins.

此链接上,对于较旧的声纳版本.他们定期触发 URL 以将查询保存在数据库缓存中.这也适用于这个问题.

At this link there was a similar issue for an older Sonar version. They triggered regularly the URL to keep the query in DB cache. This works for this issue also.

在 Jenkins 中,我安装了 http 请求插件,在发出声纳分析之前,我在 http://mySonarQube:9000/batch/project?key=myProjectKey&preview=false .这解决了真正的问题(数据库请求持续时间和超时间隔不合适),但它可以让我们保持可操作性.

In Jenkins I installed the http Request plugin and before issuing the sonar analysis I trigger a http get on http://mySonarQube:9000/batch/project?key=myProjectKey&preview=false . This works around the real problem (DB request duration and timeout interval don't fit), but it may keep us operable.

在接下来的几天里,Sonar 5.2 将会出现.我们将测试这个版本,我希望问题会消失...我会报告...

In the next few days Sonar 5.2 will occur. We will test this version and I hope there the issues will be gone... I'll report...

https://jira.sonarsource.com/projects/SONAR/versions/11629

推荐答案

问题可以通过4种方式解决:

The problem can be solved in 4 ways:

  1. SonarQube 服务器进程和/或服务器平台(例如更快的磁盘)添加更多资源
  2. 升级SonarQube服务器到最新版本(例如很多性能问题已经在SonarQube 5.2 - 参见 发行说明)
  3. 更改源中的超时值并编译自定义服务器
  4. 为数据库中的列添加索引(不推荐,您可以在调试模式下从日志中读取已执行的 SQL 命令)
  1. add more resources to SonarQube server process and/or server platform (e.g. faster disks)
  2. upgrade SonarQube server to the newest version (e.g. a lot of performance problems have been fixed in SonarQube 5.2 - see release notes)
  3. change timeout value in sources and compile custom server
  4. add indexes on columns in database (not recommended, you can read executed SQL commands from logs in debug mode)

这篇关于SonarQube 分析读取超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆