Skip to content

Commit b95558f

Browse files
committed
mysqlcluster: fix the bug about io hang xenon no switch leader #364
1 parent e5bc8b4 commit b95558f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mysqlcluster/container/mysql.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func (c *mysql) getLivenessProbe() *corev1.Probe {
9999
Command: []string{
100100
"sh",
101101
"-c",
102-
"if [ -f '/var/lib/mysql/sleep-forever' ] ;then exit 0 ; fi; pgrep mysqld",
102+
"if [ -f '/var/lib/mysql/sleep-forever' ] ;then exit 0 ; fi; " +
103+
"touch /var/lib/mysql/auto.cnf && pgrep mysqld",
103104
},
104105
},
105106
},
@@ -116,6 +117,9 @@ func (c *mysql) getReadinessProbe() *corev1.Probe {
116117
return &corev1.Probe{
117118
Handler: corev1.Handler{
118119
Exec: &corev1.ExecAction{
120+
/* /var/lib/mysql/sleep-forever is used to prevent mysql's container from exiting.
121+
kubectl exec -it sample-mysql-0 -c mysql -- sh -c 'touch /var/lib/mysql/sleep-forever'
122+
*/
119123
Command: []string{
120124
"sh",
121125
"-c",

mysqlcluster/container/mysql_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestGetMysqlLivenessProbe(t *testing.T) {
110110
livenessProbe := &corev1.Probe{
111111
Handler: corev1.Handler{
112112
Exec: &corev1.ExecAction{
113-
Command: []string{"sh", "-c", "if [ -f '/var/lib/mysql/sleep-forever' ] ;then exit 0 ; fi; pgrep mysqld"},
113+
Command: []string{"sh", "-c", "if [ -f '/var/lib/mysql/sleep-forever' ] ;then exit 0 ; fi; touch /var/lib/mysql/auto.cnf && pgrep mysqld"},
114114
},
115115
},
116116
InitialDelaySeconds: 30,

0 commit comments

Comments
 (0)