cybozu-go / moco

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.

Home Page:https://cybozu-go.github.io/moco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not kill system user

shunki-fujita opened this issue · comments

Describe the bug
KillConnections function also terminates system user processes.

moco/pkg/dbop/kill.go

Lines 19 to 30 in c545ebb

for _, p := range procs {
if constants.MocoSystemUsers[p.User] {
continue
}
if p.Host == "localhost" {
continue
}
if _, err := o.db.ExecContext(ctx, `KILL CONNECTION ?`, p.ID); err != nil && !isNoSuchThread(err) {
return fmt.Errorf("failed to kill connection %d for %s from %s: %w", p.ID, p.User, p.Host, err)
}
}

mysql> SELECT * FROM information_schema.PROCESSLIST WHERE USER="system user";
+----+-------------+-----------------+------+---------+------+----------------------------------------------------------+------+
| ID | USER        | HOST            | DB   | COMMAND | TIME | STATE                                                    | INFO |
+----+-------------+-----------------+------+---------+------+----------------------------------------------------------+------+
| 16 | system user | connecting host | NULL | Connect | 3747 | Waiting for source to send event                         | NULL |
| 17 | system user |                 | NULL | Query   |    1 | Replica has read all relay log; waiting for more updates | NULL |
| 18 | system user |                 | NULL | Query   |    1 | Waiting for an event from Coordinator                    | NULL |
| 19 | system user |                 | NULL | Query   |  347 | Waiting for an event from Coordinator                    | NULL |
| 20 | system user |                 | NULL | Connect | 3747 | Waiting for an event from Coordinator                    | NULL |
| 21 | system user |                 | NULL | Connect | 3747 | Waiting for an event from Coordinator                    | NULL |
+----+-------------+-----------------+------+---------+------+----------------------------------------------------------+------+
6 rows in set (0.00 sec)

mysql>

These processes should not kill.
If killed, data inconsistencies could occur.