I have AWS RDS - MariaDB 10.1.31, db.t2.medium
. and I always use this code to connect and close into RDS instance :
$conn = new mysqli($servername, $username, $password, $dbname);
//--- SOME CODES HERE
$conn->close();
I run my codes using cron every minute. Then I checked the process using this command :
mysql> SELECT IP_ADDRESS, COUNT(*) AS NUM FROM ( SELECT SUBSTRING(HOST, 1, CHAR_LENGTH(HOST) - 6) AS IP_ADDRESS FROM INFORMATION_SCHEMA.PROCESSLIST GROUP BY HOST ) AS t1 GROUP BY IP_ADDRESS ORDER BY IP_ADDRESS DESC;
+--------------+-----+
| IP_ADDRESS | NUM |
+--------------+-----+
| localhost | 1 |
| 172.31.9.xxx | 4 |
| 172.31.3.yy | 10 |
| 172.31.2.zzz | 1 |
+--------------+-----+
4 rows in set (0.34 sec)
I run that command every second and realise that IP address from one of EC2 instance still there even I put $conn->close();
in my codes.
it seems that the process stuck in the PROCESSLIST table.
how to immediately have PROCESSLIST table clear after $conn->close();
executed?
thank you.