Hi @anil.joshi ,
Thanks for your time, i will try to detail what i did.
1- Cluster is healthy, all members are up and running.
init state
{
"clusterName": "psdb",
"defaultReplicaSet": {
"name": "default",
"primary": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"ps-db-mysql-0.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-0.ps-db-mysql.ps-mysql:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.4.10"
},
"ps-db-mysql-1.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.4.10"
},
"ps-db-mysql-2.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-2.ps-db-mysql.ps-mysql:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.4.10"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306"
}
+---------------------------+--------------------------------------+------------------------------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+------------------------------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 2fec5bd7-9aed-11f1-bf8f-0e5e11966261 | ps-db-mysql-0.ps-db-mysql.ps-mysql | 3306 | ONLINE | SECONDARY | 8.4.10 | MySQL |
| group_replication_applier | 515fc4e2-9aed-11f1-b6ba-96a4c252d4b1 | ps-db-mysql-1.ps-db-mysql.ps-mysql | 3306 | ONLINE | PRIMARY | 8.4.10 | MySQL |
| group_replication_applier | 911ce1a2-9af6-11f1-89c6-368634cb2e7c | ps-db-mysql-2.ps-db-mysql.ps-mysql | 3306 | ONLINE | SECONDARY | 8.4.10 | MySQL |
+---------------------------+--------------------------------------+------------------------------------+-------------+--------------+-------------+----------------+----------------------------+
2- Then i deployed a network policy to simulate some network split.
network policy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: partition-ps-db-mysql-0-from-peers
namespace: ps-mysql
spec:
podSelector:
matchLabels:
pod-name: ps-db-mysql-0
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector: {}
podSelector:
matchExpressions:
- key: pod-name
operator: NotIn
values:
- ps-db-mysql-1
- ps-db-mysql-2
- ipBlock:
cidr: 0.0.0.0/0
egress:
- to:
- namespaceSelector: {}
podSelector:
matchExpressions:
- key: pod-name
operator: NotIn
values:
- ps-db-mysql-1
- ps-db-mysql-2
- ipBlock:
cidr: 0.0.0.0/0
3- After the network policy we could see the expected cluster state, 1 node missing:
Cluster state after "network failure"
cluster.status()
{
"clusterName": "psdb",
"defaultReplicaSet": {
"name": "default",
"primary": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE_PARTIAL",
"statusText": "Cluster is NOT tolerant to any failures. 1 member is not active.",
"topology": {
"ps-db-mysql-0.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-0.ps-db-mysql.ps-mysql:3306",
"memberRole": "SECONDARY",
"mode": "n/a",
"readReplicas": {},
"role": "HA",
"shellConnectError": "MySQL Error 2003: Could not open connection to 'ps-db-mysql-0.ps-db-mysql.ps-mysql:3306': Can't connect to MySQL server on 'ps-db-mysql-0.ps-db-mysql.ps-mysql:3306' (110)",
"status": "(MISSING)"
},
"ps-db-mysql-1.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.4.10"
},
"ps-db-mysql-2.ps-db-mysql.ps-mysql:3306": {
"address": "ps-db-mysql-2.ps-db-mysql.ps-mysql:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.4.10"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "ps-db-mysql-1.ps-db-mysql.ps-mysql:3306"
}
Shortly after the “network failure” the pod gets not ready and the container is restarted.
The pod gets back without any intervention, meaning still in “network failure” to ready state.
In that pod we can find:
cat /var/lib/mysql/full-cluster-crash
2fec5bd7-9aed-11f1-bf8f-0e5e11966261:1-9,3d6d74ae-9aed-11f1-a0a7-0e5e11966261:1-137
4- Once the network policy is removed, “network failure is solved”
All the mysql pods get deleted, even if all the time until now the cluster was up and running with 2 instances as shown in the previous point.
In attach the logs from all instances and operator, one key log i found from the operator is:
Crash recovery Tried to reboot the cluster but MySQL says the cluster is already online. Deleting all MySQL pods.
I tried to split the logs into moments, so expect to find some new lines with a comment.
Thanks