由于SocketTimeoutException,Sonar报告的上传失败 [英] Upload of Sonar report fails due to SocketTimeoutException

查看:415
本文介绍了由于SocketTimeoutException,Sonar报告的上传失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到的问题类似于声纳分析失败,并出现SocketTimeoutException

We have a problem similar to those already discussed in Sonar analysis fails with SocketTimeoutException and Read timed out on SonarQube analysis but it happens to us in version 5.6.2. We have a large number of sonar analyses as a series of nightly builds starting at midnight and ending in the early morning. Only the first analysis (sometimes the first couple of analyses) are affected by a SocketTimeoutException during the upload of the report:

[exec] 00:15:33.724 DEBUG: Upload report
[exec] 00:16:34.065 INFO: ------------------------------------------------------------------------
[exec] 00:16:34.065 INFO: EXECUTION FAILURE
[exec] 00:16:34.065 INFO: ------------------------------------------------------------------------
[exec] 00:16:34.065 INFO: Total time: 1:28.329s
[exec] 00:16:34.320 ERROR: Error during SonarQube Scanner execution
[exec] java.lang.IllegalStateException: Fail to request http://mysonar:9000/sonar/api/ce/submit?projectKey=myproject&projectName=myproject
[exec]  at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:212)
[exec]  at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:175)
[exec]  at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:146)
[exec]  at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:67)
[exec]  at org.sonar.batch.report.ReportPublisher.upload(ReportPublisher.java:172)
[exec]  at org.sonar.batch.report.ReportPublisher.execute(ReportPublisher.java:127)
[exec]  at org.sonar.batch.phases.PublishPhaseExecutor.publishReportJob(PublishPhaseExecutor.java:64)
[exec]  at org.sonar.batch.phases.PublishPhaseExecutor.executeOnRoot(PublishPhaseExecutor.java:51)
[exec]  at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:86)
[exec]  at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
[exec]  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[exec]  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[exec]  at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
[exec]  at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
[exec]  at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
[exec]  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[exec]  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[exec]  at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
[exec]  at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
[exec]  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[exec]  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[exec]  at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
[exec]  at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
[exec]  at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
[exec]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[exec]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[exec]  at java.lang.reflect.Method.invoke(Method.java:498)
[exec]  at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
[exec]  at com.sun.proxy.$Proxy0.execute(Unknown Source)
[exec]  at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
[exec]  at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
[exec]  at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
[exec]  at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
[exec]  at org.sonarsource.scanner.cli.Main.main(Main.java:61)
[exec] Caused by: java.net.SocketTimeoutException: timeout
[exec]  at okio.Okio$3.newTimeoutException(Okio.java:207)
[exec]  at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
[exec]  at okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
[exec]  at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
[exec]  at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
[exec]  at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
[exec]  at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
[exec]  at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:79)
[exec]  at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:909)
[exec]  at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:93)
[exec]  at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:894)
[exec]  at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:748)
[exec]  at com.squareup.okhttp.Call.getResponse(Call.java:277)
[exec]  at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:234)
[exec]  at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:196)
[exec]  at com.squareup.okhttp.Call.execute(Call.java:79)
[exec]  at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:209)
[exec]  ... 34 more
[exec] Caused by: java.net.SocketException: Socket closed
[exec]  at java.net.SocketInputStream.read(SocketInputStream.java:204)
[exec]  at java.net.SocketInputStream.read(SocketInputStream.java:141)
[exec]  at okio.Okio$2.read(Okio.java:139)
[exec]  at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
[exec]  ... 48 more
[exec] 00:16:34.322 ERROR: 
[exec] 00:16:34.322 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[exec] 00:16:34.320 INFO: Final Memory: 59M/426M
[exec] 00:16:34.320 INFO: ------------------------------------------------------------------------
[exec] Result: 1
[echo] Sonar execution failed, please check the log

通常,上传仅需几毫秒(对于最大的项目而言,大约需要200毫秒),而在这种情况下,60秒后似乎会出现超时(00:15:33上载,00:16:34失败).同时,服务器上的access.log显示了一个非常奇怪的模式:POST /sonar/api/ce/submit于00:21:39到达服务器,这是初始上传请求之后的六分钟,而客户端收到TimeoutException之后的五分钟(并且客户端和服务器的时钟完全同步).

Normally, the upload takes just milliseconds (around 200ms for the largest projects), while in this case a timeout seems to occur after 60 seconds (upload at 00:15:33, failure at 00:16:34). At the same time, the access.log at the server shows a very strange pattern: the POST /sonar/api/ce/submit arrives at the server at 00:21:39, six minutes after the initial upload request and five minutes after the client received the TimeoutException (and the clocks of the client and server are perfectly in sync).

10.0.206.160 - - [13/Mar/2017:00:15:09 +0100] "GET /sonar/batch/project.protobuf?key=myprojectkey HTTP/1.1" 200 2556 "-" "SonarQubeRunner/2.7"
10.0.206.160 - - [13/Mar/2017:00:15:09 +0100] "GET /sonar/api/qualityprofiles/search.protobuf?projectKey=myprojectkey HTTP/1.1" 200 909 "-" "SonarQubeRunner/2.7"
10.0.206.160 - - [13/Mar/2017:00:21:39 +0100] "POST /sonar/api/ce/submit?projectKey=myprojectkey&projectName=myproject HTTP/1.1" 200 60 "-" "SonarQubeRunner/2.7"

即使是陌生人,Sonar GUI实际上也会显示所有分析结果以及初始上载时间的时间戳记(在客户端为00:15),并且后台任务"视图显示以下时间戳记:Submitted = 12:15:33 AM ,开始= 12:22:03 AM,完成= 12:22:08 AM. 基本上,从分析的角度来看,一切都可以正常工作,但是由于超时异常,构建仍然会失败.

Even stranger, the Sonar GUI actually presents all the analysis results with the timestamp of the initial upload time (at the client, 00:15) and the Background Tasks view shows the following timestamps: submitted=12:15:33 AM, started=12:22:03 AM, finished=12:22:08 AM. Basically, everything works from an analysis point of view, but still the build still fails due to the timeout exception.

推荐答案

此问题特定于我们的设置.这是由于Sonar数据库备份与某些夜间构建同时运行而造成的.在mysqldump运行创建备份的大约20分钟内,当客户端尝试上传分析报告时,Sonar服务变得完全无响应,并导致SocketTimeoutException.

This problem is particular to our setup. It was caused by a Sonar database backup running simultaneously with some of the nightly builds. During the ~20min that mysqldump is running to create a backup, the Sonar services get totally unresponsive and results in a SocketTimeoutException when clients try uploading the analysis report.

这种情况下的解决方案:将数据库备份移至Sonar空闲的时间.

Solution in this case: move the DB backup to a time when Sonar is idle.

这篇关于由于SocketTimeoutException,Sonar报告的上传失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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