当前位置:网站首页>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 .
边栏推荐
- EMC rectification method set
- EMC中class A和class B哪个更严格?
- [solution] visual full link log tracking - log tracking system
- Dry goods | share an EMC actual case and rectification process
- Tensorflow uses deep learning (II)
- 细说共模干扰和差模干扰
- DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂
- ArcGIS JS map internal and external network environment judgment
- 【13】加法器:如何像搭乐高一样搭电路(上)?
- EMC整改思路
猜你喜欢

@The role of documented

【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(八)

Opencv's practical learning of credit card recognition (4)
![[JVM optimization] online JVM tuning practice](/img/e3/5fa128805af0ca03f0b6715b78d398.jpg)
[JVM optimization] online JVM tuning practice

03 | project deployment: how to quickly deploy a website developed based on the laravel framework

【17】 Establish data path (upper): instruction + operation =cpu

近红外二区AgzS量子点包裹脱氧核糖核酸DNA|DNA-AgzSQDs(齐岳)

2022年湖南工学院ACM集训第五次周测AD题题解

Basic dictionary of deep learning --- activation function, batch size, normalization

【13】加法器:如何像搭乐高一样搭电路(上)?
随机推荐
DNA-Ag2SQDs脱氧核糖核酸DNA修饰硫化银Ag2S量子点的合成方法
EMC's "don't come back until you rectify"
Will ordinary browsers disclose information? How to protect privacy by using a secure browser?
[dry goods] 32 EMC standard circuits are shared!
JUC原子类: CAS, Unsafe、CAS缺点、ABA问题如何解决详解
【13】加法器:如何像搭乐高一样搭电路(上)?
03 | 项目部署:如何快速部署一个基于laravel框架开发的网站
OpenTSDB-时序数据库
“蔚来杯“2022牛客暑期多校训练营2补题记录(DGHJKL)
磁环选型攻略及EMC整改技巧
Redis of non relational database [detailed setup of redis cluster]
ArcGIS JS customizes the accessor and uses the watchutils related method to view the attribute
Use ffmpeg to generate single image + single audio streaming video in batches
Collection | combined with my personal experience, I have summarized these seven EMC related knowledge
常用电子产品行业标准及认证
leetcode 字符串类
非关系型数据库之Redis【redis安装】
Freezing and thawing of pytoch
What are the different tables in MySQL?
机械革命蛟龙p有线网卡驱动打不上