问题现象
在 OCP Web 白屏界面上执行运维任务时在 Active agent modules 子任务这一步一直遇到报错 java.net.SocketTimeoutException: Read timed out。反复重试失败的子任务均无法成功,如下图所示。

详细日志信息如下:
2025-05-19 21:20:16.182 INFO 10 --- [manual-subtask-executor16,a208b269766e6629,b4cab528602bdaf7] c.o.o.e.internal.template.HttpTemplate : POST request to agent, url:http://xx.xxx.211.54:62888/api/v1/module/config/update, request body:UpdateAgentConfigRequest(agentHome=null, configs=[(monagent.pipeline.ob.status=active), (monagent.pipeline.session.status=active), (monagent.pipeline.plan.monitor.status=active), (monagent.pipeline.plan.monitor.status=active), (monagent.pipeline.transaction.status=active), (monagent.pipeline.sql.audit.status=active), (monagent.pipeline.sql.plan.status=active), (monagent.pipeline.slow.sql.status=active), (ob.logcleaner.enabled=true), (ob.logtailer.enabled=true)]), params:null
2025-05-19 21:20:46.219 ERROR 10 --- [manual-subtask-executor16,a208b269766e6629,b4cab528602bdaf7] c.o.o.c.t.e.c.w.subtask.SubtaskExecutor : Read timed out
java.net.SocketTimeoutException: Read timed out
at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:288)
at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:314)
at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:355)
at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:808)
at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:471)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$2(JerseyInvocation.java:687)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:697)
at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:691)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:691)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:686)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:461)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
at com.oceanbase.ocp.executor.internal.template.HttpTemplate.lambda$doPost$2(HttpTemplate.java:288)
at com.oceanbase.ocp.executor.internal.template.HttpTemplate.safeExecute(HttpTemplate.java:492)
at com.oceanbase.ocp.executor.internal.template.HttpTemplate.doPost(HttpTemplate.java:288)
at com.oceanbase.ocp.executor.internal.template.HttpTemplate.post(HttpTemplate.java:117)
at com.oceanbase.ocp.executor.executor.AgentExecutor.updateAgentConfig(AgentExecutor.java:196)
at com.oceanbase.ocp.compute.agent.manager.HostAgentConfigManagerImpl.configAgent(HostAgentConfigManagerImpl.java:745)
at com.oceanbase.ocp.compute.agent.manager.HostAgentConfigManagerImpl.configAgent(HostAgentConfigManagerImpl.java:753)
at com.oceanbase.ocp.compute.agent.manager.HostAgentConfigManagerImpl.activeObModule(HostAgentConfigManagerImpl.java:675)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:723)
at com.oceanbase.ocp.compute.agent.manager.HostAgentConfigManagerImpl$$SpringCGLIB$$0.activeObModule(<generated>)
at com.oceanbase.ocp.compute.agent.HostAgentServiceImpl.activeObModule(HostAgentServiceImpl.java:812)
at com.oceanbase.ocp.compute.agent.HostAgentServiceImpl.activeAgentModule(HostAgentServiceImpl.java:429)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:723)
at com.oceanbase.ocp.compute.agent.HostAgentServiceImpl$$SpringCGLIB$$0.activeAgentModule(<generated>)
at com.oceanbase.ocp.service.task.business.obagent.ActiveAgentModuleTask.run(ActiveAgentModuleTask.java:42)
at com.oceanbase.ocp.core.task.engine.runner.JavaSubtaskRunner.execute(JavaSubtaskRunner.java:64)
at com.oceanbase.ocp.core.task.engine.runner.JavaSubtaskRunner.doRun(JavaSubtaskRunner.java:32)
at com.oceanbase.ocp.core.task.engine.runner.JavaSubtaskRunner.run(JavaSubtaskRunner.java:26)
at com.oceanbase.ocp.core.task.engine.runner.RunnerFactory.doRun(RunnerFactory.java:76)
at com.oceanbase.ocp.core.task.engine.coordinator.worker.subtask.SubtaskExecutor.doRun(SubtaskExecutor.java:213)
at com.oceanbase.ocp.core.task.engine.coordinator.worker.subtask.SubtaskExecutor.redirectConsoleOutput(SubtaskExecutor.java:207)
at com.oceanbase.ocp.core.task.engine.coordinator.worker.subtask.SubtaskExecutor.lambda$submit$2(SubtaskExecutor.java:137)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Set state for subtask: 3173026, operation:EXECUTE, state: FAILED
问题原因
问题的直接原因是在 2025-05-19 21:20:16.182 时间点发送给 ocp_mgragent 进程的 RESTful API 请求在 2025-05-19 21:20:46.219 时刻仍未收到任何的回复,该请求的响应时间已经超过了默认设置的超时阈值 30s,导致 Web 前端报错 java.net.SocketTimeoutException: Read timed out。
出现该响应超时的可能原因有两个:
原因一: 对应主机的
ocp_mgragent进程或ocp_monagent进程在那段时间较为繁忙,CPU 使用率接近上限(可以分别通过top -p $(pidof ocp_mgragent)和top -p $(pidof ocp_monagent)命令来查看这两个 OCP 进程的当前实际 CPU 利用率),请求处理能力下降。原因二: 是 OCP V4.3.5 早期版本的
ocp_monagent进程未指定GOMAXPROCS,导致ocp_monagent进程修改配置的任务被 CPU 挂起,从而导致超时。
问题的风险及影响
OCP Web 白屏界面任务中心的子任务执行一直失败。
适用版本
OCP V3.2.x 及更高的版本。
解决方法
如果是
ocp_mgragent进程较忙,可以调大ocp_mgragent进程可用的资源,由默认的 1C2G 调大为 2C4G 或更大。[root@observer log]# /home/admin/ocp_agent/bin/ocp_agentctl config list | python -m json.tool | grep mgragent "mgragent.limit.cpu.quota": "1.0", "mgragent.limit.memory.quota": "2048MB", "mgragent.log.compress": "true", "mgragent.log.level": "info", "mgragent.log.maxage.days": "30", "mgragent.log.maxbackups": "15", "mgragent.log.maxsize.mb": "200", [root@observer ~]# /home/admin/ocp_agent/bin/ocp_agentctl config -u mgragent.limit.cpu.quota=2.0 {"successful":true,"message":"success","error":""}[root@observer ~]# [root@observer ~]# /home/admin/ocp_agent/bin/ocp_agentctl config -u mgragent.limit.memory.quota=4096MB {"successful":true,"message":"success","error":""}[root@observer ~]# [root@observer ~]# // 执行完上面的命令后,需要重启 ocp_agent 才能生效 [root@observer ~]# systemctl restart ocp_agent调大
ocp_mgragent执行管控任务的超时阈值。连接到 OCP 的 MetaDB 中修改
config_properties表,更新如下两个私有参数的取值:ocp.operation.executor.http.socket-timeout <== 默认为 3s,根据需要酌情增大
ocp.operation.executor.http.read-timeout <== 默认 30s,根据需要酌情增大
[root@ocp ~]# mysql -hxx.xxx.211.51 -P2881 -uroot@ocp_meta -pxxx -A -c ocp Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221620939 Server version: 5.7.25 OceanBase 4.2.1.7 (r107030032024062709-7d62d41478c39e4512cd694d1019a69dcc7efb63) (Built Jun 27 2024 10:13:11) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [ocp]> select * from config_properties where `key`="ocp.operation.executor.http.socket-timeout"\G *************************** 1. row *************************** id: 327 key: ocp.operation.executor.http.socket-timeout default_value: 3000 value: NULL need_restart: 1 application: ocp profile: default label: master visible_level: PRIVATE description: http客户端,建立Socket连接的超时时间,默认3s create_time: 2024-10-30 15:18:31 update_time: 2024-10-30 15:18:31 description_en: HTTP client, the timeout period for establishing a Socket connection, the default is 3s is_az_level: 0 type: NUMERIC 1 row in set (0.002 sec) MySQL [ocp]> select * from config_properties where `key`="ocp.operation.executor.http.read-timeout"\G *************************** 1. row *************************** id: 329 key: ocp.operation.executor.http.read-timeout default_value: 30000 value: NULL need_restart: 1 application: ocp profile: default label: master visible_level: PRIVATE description: http读取数据的超时时间,单位 ms,默认30s create_time: 2024-10-30 15:18:31 update_time: 2024-10-30 15:18:31 description_en: HTTP timeout for reading data, unit is ms, the default is 30s is_az_level: 0 type: NUMERIC 1 row in set (0.000 sec) MySQL [ocp]> update config_properties set value=10000 where `key`="ocp.operation.executor.http.socket-timeout"; Query OK, 1 row affected (0.004 sec) Rows matched: 1 Changed: 1 Warnings: 0 MySQL [ocp]> update config_properties set value=60000 where `key`="ocp.operation.executor.http.read-timeout"; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MySQL [ocp]> commit; Query OK, 0 rows affected (0.000 sec)注意: 这两个私有参数的
need_restart均为 1,因此需要重启所有相关 OCP 容器才能生效。[root@ocp ~]# docker restart ocp
可以选择上面两个方法中的其中一个,执行后重试 OCP Web 任务中心失败的子任务即可。