问题现象
使用 JAVA 客户端连接 OceanBase 数据库时,发生报错:Application was streaming results when the connection failed. Consider raising value of 'net_write_timeout' on the server.。
问题原因
net_write_timeout 变量的值设置过小。
问题的风险及影响
当服务器向客户端写数据时,系统变量 net_write_timeout 可以控制连接中断的超时时间。在连接繁忙时,如果该值过小,则会发生报错,连接中断。
影响的版本
- OceanBase 数据库企业版 V3.2.x
- OceanBase 数据库企业版 V4.x.x
解决方法及规避方式
通过客户端登录 OceanBase 数据库,查看系统变量
net_write_timeout的值。该变量的取值范围为 [1, 31536000],默认值为 60 秒,详细信息请参见 net_write_timeout。obclient> SHOW VARIABLES LIKE 'net_write_timeout'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | net_write_timeout | 60 | +-------------------+-------+ 1 row in set调大该租户的
net_write_timeout变量值,示例如下。然后需要重连客户端。obclient> SET GLOBAL NET_WRITE_TIMEOUT = 28800;或者在 JDBC 连接串中调整
net_write_timeout的值,示例如下:jdbc:mysql://127.xxx.xxx.xxx:2883/db_name?rewriteBatchedStatements=true&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&sessionVariables=ob_read_consistency=weak,ob_query_timeout=300000000,ob_trx_timeout=300000000,net_write_timeout=28800jdbc:oceanbase://10.XXX.XXX.XXX:1001/databasename?user=**u**@sys&password=******&pool=false&useBulkStmts=true&rewriteBatchedStatements=false&useServerPrepStmts=true&sessionVariables=ob_read_consistency=weak,ob_query_timeout=300000000,ob_trx_timeout=300000000,net_write_timeout=28800