レプリケーション ドライバーを使用しcom.mysql.jdbc.ReplicationDriver
ており、jdbc を使用して接続を構成しています
jdbc.de.url=jdbc:mysql:replication://master:3306,slave:3306/lieferando_de?zeroDateTimeBehavior=convertToNull&characterEncoding=UTF-8&tcpKeepAlive=true
c3p0 は、プールされた接続を 30 秒ごとにテストするように構成されています。
<bean id="basisDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" abstract="true">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="30" />
<property name="maxIdleTime" value="14400" />
<property name="maxConnectionAge" value="14400" />
<property name="testConnectionOnCheckout" value="false" />
<property name="idleConnectionTestPeriod" value="30" />
<property name="preferredTestQuery" value="SELECT 1" />
</bean>
しかし、テストされているのはマスターだけです
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0 Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@6b6a16ae] on IDLE CHECK.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1 Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5c219c51] on IDLE CHECK.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2 Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7e350225] on IDLE CHECK.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1 Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5c219c51] on IDLE CHECK has SUCCEEDED.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1 Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@602f892f] on IDLE CHECK.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0 Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@6b6a16ae] on IDLE CHECK has SUCCEEDED.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0 Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7deb41d6] on IDLE CHECK.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2 Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7e350225] on IDLE CHECK has SUCCEEDED.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1 Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@602f892f] on IDLE CHECK has SUCCEEDED.
[DEBUG] 25.06.2013 13:29:30 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0 Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7deb41d6] on IDLE CHECK has SUCCEEDED.
最初はマスターとスレーブへの接続が開いており、カウントは 5 です。
macbookpro-533f:~ mlaug$ netstat -nat | grep 3306
tcp4 0 0 10.10.14.181.57215 slave.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57214 slave.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57213 master.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57212 master.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57211 slave.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57209 slave.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57210 slave.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57208 master.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57207 master.3306 ESTABLISHED
tcp4 0 0 10.10.14.181.57206 master.3306 ESTABLISHED
しかし、スレーブ接続はちょうど 5 分後に消え、アプリケーションはBroken Pipe Exception
.
c3p0
スレーブ接続もテストするように構成するにはどうすればよいですか?