配置主从同步时

来源:5-2 主从同步数据库配置

帅炸一片天

2017-10-15

配置都已经做好了。。

在做代码修改时候 连接主库能够 test返回正确数值

连接从库的时候 test就不能返回了 开始报错 

 com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@5bda37c7 -- APPARENT DEADLOCK!!! Complete Status: 
	Managed Threads: 3
	Active Threads: 3
	Active Tasks: 
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1420c8f7 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1eceb1bb (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@25fe1b0c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
	Pending Tasks: 
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@66fa3ce0
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@740f37b8
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1f2713eb
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4ad44d78
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@7dfe75fe
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@70412f0e
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@57dec2a6
Pool thread stack traces:
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
		java.net.DualStackPlainSocketImpl.connect0(Native Method)
		java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
		java.net.AbstractPlainSocketImpl.connect(Unknown Source)
		java.net.PlainSocketImpl.connect(Unknown Source)
		java.net.SocksSocketImpl.connect(Unknown Source)
		java.net.Socket.connect(Unknown Source)
		com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:214)
		com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
		com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2252)
		com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2285)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2084)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
		com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
		sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
		sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
		sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
		java.lang.reflect.Constructor.newInstance(Unknown Source)
		com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
		com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
		com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
		com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
		java.net.DualStackPlainSocketImpl.connect0(Native Method)
		java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
		java.net.AbstractPlainSocketImpl.connect(Unknown Source)
		java.net.PlainSocketImpl.connect(Unknown Source)
		java.net.SocksSocketImpl.connect(Unknown Source)
		java.net.Socket.connect(Unknown Source)
		com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:214)
		com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
		com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2252)
		com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2285)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2084)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
		com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
		sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
		sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
		sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
		java.lang.reflect.Constructor.newInstance(Unknown Source)
		com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
		com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
		com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
		com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
	Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
		java.net.DualStackPlainSocketImpl.connect0(Native Method)
		java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
		java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
		java.net.AbstractPlainSocketImpl.connect(Unknown Source)
		java.net.PlainSocketImpl.connect(Unknown Source)
		java.net.SocksSocketImpl.connect(Unknown Source)
		java.net.Socket.connect(Unknown Source)
		com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:214)
		com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
		com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2252)
		com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2285)
		com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2084)
		com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
		com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
		sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
		sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
		sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
		java.lang.reflect.Constructor.newInstance(Unknown Source)
		com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
		com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
		com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
		com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
		com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
		com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
		com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
		com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
		com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
		com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)


十月 15, 2017 2:03:00 下午 org.springframework.context.support.GenericApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@2a2d45ba: startup date [Sun Oct 15 14:02:39 CST 2017]; root of context hierarchy


写回答

1回答

翔仔

2017-10-16

炸哥,不好意思昨天有事要处理没有及时回复,这个显示我看是死锁了,如果去掉主从库,即主库从库都设置为从库,去读下从库数据看看,记住是读,千万不要写,不然就报错了,还有在从库上执行show slave status \G看看 并且从你本地的mysql客户端连接从库看看,看看能否连上,连不上对比下配置

0
0

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程