WeBWorK Main Forum

WeBWorK not closing MySQL connections in a proper way

WeBWorK not closing MySQL connections in a proper way

by Alex Persson -
Number of replies: 0
Hi,

We are running Ubuntu 16.04 LTS server with WeBWorK develop version from January 8, 2017, with MySQL server 5.7 (5.7.19-0ubuntu0.16.04.1). All of it resides on a virtual host on a VMware vCenter server.

During exam about 40 to 50 students logs in to our WeBWorK server within about 30 to 60 seconds when the exam starts. During those 30 to 60 seconds we sometimes get "Too many connections" in the Apache error-log and we also see many "Aborted connection ... Got an error reading communication packets" in /var/log/mysql/error.log. We guess that the problem might be that WeBWorK does not close the MySQL connection in a proper way so that MySQL has do do that instead and then reports "Aborted connection".

When studying /var/log/mysql/error.log during the first minute when most users logs in it seems like MySQL only removes bad connections once every second and at that occasion removes a maximum of two bad connections since /var/log/mysql/error.log looks like this if studying the first ten lines:

2017-10-25T08:01:00.760121Z 889810 [Note] Aborted connection 889810 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:00.760236Z 889808 [Note] Aborted connection 889808 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:01.761992Z 889829 [Note] Aborted connection 889829 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:01.761992Z 889827 [Note] Aborted connection 889827 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:03.763331Z 889709 [Note] Aborted connection 889709 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:03.763349Z 889712 [Note] Aborted connection 889712 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:05.765593Z 889801 [Note] Aborted connection 889801 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:05.765701Z 889795 [Note] Aborted connection 889795 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:07.769540Z 889729 [Note] Aborted connection 889729 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)
2017-10-25T08:01:07.769725Z 889720 [Note] Aborted connection 889720 to db: 'webwork' user: 'webworkWrite' host: 'localhost' (Got an error reading communication packets)

1. Anyone know why it seems that WeBWorK does not close the MySQL connections in a proper way and how to trace the source of the problem to try to fix it?

2. A temporary fix to not get "Too many connections" while we are looking at how we can get WeBWorK to start closing the MySQL connections in a proper way would be to have MySQL look for bad connections more than once every second or to have MySQL to be able to remove more than two bad connections at that occasion. Any idea how to do that? (we have already increased MySQL max_connections to 214 but that seems not to be enough)

Thanks in advance,
Alex