当前位置:网站首页>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 .
边栏推荐
- 【17】建立数据通路(上):指令+运算=CPU
- DNA modified rhodium RH nanoparticles rhnps DNA (DNA modified noble metal nanoparticles)
- The underlying principles of RDB persistence and AOF persistence of redis
- SWM32系列教程5-ADC应用
- Parse tree structure JS
- awk从入门到入土(16)awk变量类型探讨--关于数字和string两种类型
- JUC atomic class: CAS, unsafe, CAS shortcomings, how to solve ABA problems in detail
- RFID辐射测试小结
- XSS知识点和20字符短域名绕过
- ArcGIS JS自定义Accessor,并通过watchUtils相关方法watch属性
猜你喜欢

XMPP Service Research (II) prosody create account

CLion调试redis6源码

Learn software testing in two weeks? I was shocked!

DNA-CuInSeQDs近红外CuInSe量子点包裹脱氧核糖核酸DNA

非关系型数据库之Redis【redis集群详细搭建】

Collection | combined with my personal experience, I have summarized these seven EMC related knowledge

DNA modified osmium OS nanoparticles osnps DNA modified iridium nanoparticles irnps DNA

Daily question - split equal sum subset
![[JVM optimization ultra detailed] common JVM tuning scenarios](/img/dd/3fed0b2bb6f00e5719982e38495e5c.jpg)
[JVM optimization ultra detailed] common JVM tuning scenarios

谈谈DOM0,DOM1,DOM2,DOM3
随机推荐
EMC设计攻略 —时钟
leetcode 字符串类
Using identity framework to realize JWT identity authentication and authorization in.Net 6.0
DNA modified osmium OS nanoparticles osnps DNA modified iridium nanoparticles irnps DNA
Clion debugging redis6 source code
DNA修饰贵金属纳米颗粒|DNA修饰纳米铜颗粒CuNPS-DNA|研究要点
Will ordinary browsers disclose information? How to protect privacy by using a secure browser?
细说共模干扰和差模干扰
EMC's "don't come back until you rectify"
EMC之 “不整改好别回来了”
ESD防护为何对集成电路如此重要?又该如何防护?
Merge two sorted linked lists - two questions per day
[dry goods] 32 EMC standard circuits are shared!
Protobuf basic grammar summary
DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂
Qt使用信号量控制线程(QSemaphore)
DNA修饰金属铑Rh纳米颗粒RhNPS-DNA(DNA修饰贵金属纳米颗粒)
Flowable workflow all business concepts
Chapter 01 introduction of [notes of Huashu]
How do we run batch mode in MySQL?