当前位置:网站首页>Record a MYCAT connection and solve the problems of communications link failure
Record a MYCAT connection and solve the problems of communications link failure
2022-07-28 07:57:00 【Both refined and popular tastes zyyyyyy】
Project scenario :
Multithreading processing data push : Yes A and B Two tables ,A Table is MySQL Connect ,B Table is Mycat Connect , Each has 200 Split sheet ,A and B Joint query splicing data is pushed to other systems for use . The current scheme is A surface 1-200 Read data page by page in separate tables , Get id Gather to B Logical table query of table , Splicing data .
Problem description
Adjust the page size to 1000, The program reports an error after running for a period of time , The specific errors are as follows , Later, the paging size was reduced , No report error , And then adjust to 5000, The running time of the program is greatly reduced and errors are reported .
[2022-07-20 16:36:30.723] [ Public area data query thread 781294] [WARN ] com.zaxxer.hikari.pool.ProxyConnection - HikariPool-1 - Connection [email protected] marked as broken because of SQLSTATE(08S01), ErrorCode(0)
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1,882 milliseconds ago. The last packet sent successfully to the server was 1,883 milliseconds ago.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
at com.sun.proxy.$Proxy54.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:128)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy58.querySource(Unknown Source)
at gov.zwfw.iam.datacutover.service.impl.NaturalServiceImpl.moveData(NaturalServiceImpl.java:63)
at gov.zwfw.iam.datacutover.thread.NaturalDataThread.run(NaturalDataThread.java:43)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
Cause analysis :
This problem begins to appear , I started from navicat I inquired about sql The state of ,SHOW FULL PROCESSLIST; Found most of sql Of state by Waiting for query cache lock,
So search this question , It is found that there is a problem with query caching , And then according to show status like '%Qcache%'; Query cache related information , as follows 
according to show variables like '%query_cache%'; Query cache settings 
After querying relevant documents , Query cache is turned off , Get into mysql Of my.cnf file , Set the following two properties 
All in one operation , Restart the program ,sql The state is no problem , however , After a period of time, it still reports an error , It's just a little longer , therefore , Check this question again , Some documents say that the timeout of idle connection has exceeded mysql Connection time , therefore , Inquire about mysql Connection timeout for ,show global variables like "wait_timeout";
The beginning is 3000, Then I set the timeout as the default 8 Hours , namely 28800,set global wait_timeout=28800; Note that this operation must be in MySQL Connect , Or just modify it my.cnf file 
meanwhile , The following configuration is set on the program configuration
validationQuery: SELECT 1
testWhileIdle: true
timeBetweenEvictionRunsMillis: 28000
And then restart the program , After a while , Report errors .............
This operation down , It has wasted my whole day , If you don't do well, you will be scolded , Still, , It occurred to me that , It's always been mycat Connection error , Then I read the log , Find out console.log The log will be reported after the program reports an error oom, Is it right? mycat There's something wrong with the settings for , therefore , Open the mycat Configuration of , see wrapper.conf file , It is found that a direct memory configuration is 2g, Then I had a whim to try this bigger , Changed to 8g, This time, , The program runs longer , But the error is still reported in the end 
Then I took a look mycat Log , The operation log has been brushing sql, At this time , With my eyes, I found the problem 

Execute a in the logic table sql, It needs to be executed once in each partition table , It's so immortal that I use it here in Go to query , At this time, I probably understood , Due to the increasing amount of data , Queries slow down , No connection caused mycat Feign death , This is why it's OK to reduce the page size , And restart after reporting an error mycat It's still working .
Solution :
take mycat At the time of inquiry in Range query is changed to equivalent query , such , Although every time I have to go to the circulation Library , But at least the program ran , The performance of circular query is also better than the previous in Range query is much faster , meanwhile , The paging size can also be set to a larger value , Problem solving .
边栏推荐
- 辨析覆盖索引/索引覆盖/三星索引
- GD32使用ST的HAL库和GD官方库的一些体会
- RFID辐射测试小结
- EMC design strategy - clock
- win系统添加打印机
- EMC rectification method set
- Awk from introduction to earth (16) discussion on the types of awk variables -- about the two types of numbers and strings
- Elaborate on common mode interference and differential mode interference
- DNA modified noble metal nanoparticles | DNA deoxyribonucleic acid modified metal palladium Pd nanoparticles pdnps DNA
- EMC问题的根源在哪?
猜你喜欢

03 | 项目部署:如何快速部署一个基于laravel框架开发的网站

EMC设计攻略 —时钟

GD32使用ST的HAL库和GD官方库的一些体会

EMC中class A和class B哪个更严格?

解析树形结构 js

Parse tree structure JS

The first common node of two linked lists -- two questions per day

演讲笔记 适合所有人的实用程序生成 PCG
![[solution] visual full link log tracking - log tracking system](/img/0c/f93c7d31e01257c5dee7d292ac7d84.jpg)
[solution] visual full link log tracking - log tracking system

DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂
随机推荐
How to understand the adjective prefix of socket: "connection oriented" and "connectionless"
Swm32 series tutorial 5-adc application
解析树形结构 js
How do we run batch mode in MySQL?
mysql,可以使用多少列创建索引?
【google】解决google浏览器不弹出账号密码保存框且无法保存登录信息问题
SWM32系列教程5-ADC应用
Pytorch的冻结以及解冻
03 | 项目部署:如何快速部署一个基于laravel框架开发的网站
【青鸟学员故事】追风少年“李晓亮”
Collection | combined with my personal experience, I have summarized these seven EMC related knowledge
磁环选型攻略及EMC整改技巧
ASP. Net core technology insider and project practice after reading
GD32使用ST的HAL库和GD官方库的一些体会
Some experience of gd32 using Hal Library of ST and Gd official library
2022/7/27 examination summary
awk从入门到入土(16)awk变量类型探讨--关于数字和string两种类型
win系统添加打印机
数据化管理洞悉零售及电子商务运营——数据化管理介绍
Matplotlib绘图笔记基础直线、折线、曲线