I know this question has been asked many times but I have tried all of the solutions I've come across and none have worked. I hope someone might be able to shed some light.
I have set the following INI settings to very large values:
mysql.connect_timeout
default_socket_timeout
max_execution_time
I have also called set_time_limit(0)
at the beginning of my script. What other PHP INI settings should I try?
I am very sure the settings on the MySQL server are adequate for very large queries because another server with PHP is able to run the script I'm trying to run without a problem. It waits forever for MySQL to finish and then continues. That's exactly what I want in this php:5-apache
container of mine.
On the server that works, mysql.connect_timout
is only set to 60, but the script maintains a connection to the mysql server for much longer, leading me to believe some other setting is at issue. default_socket_timeout
is also set to 60 on this server. What???
I was really hoping it was default_socket_timeout
, but no matter what number I set, it does not change how the "Mysql server has gone away" error appears in about 60 seconds.
I also tried using mysql_ping
. That didn't make any difference either.
The script is using the old mysql
functions. I do want to upgrade this, but first I want to know why it works on the other server and not mine.
Also, I can see that the mysql server is still processing the giant query when I do SHOW PROCESSLIST
.
What the heck am I missing? I really think it is an INI setting that this other server has that my container does not, but I am copying all the settings that appear relevant yet. Why can another server with PHP run the script and properly wait however long it needs for mysql yet I can't seem to make that happen in the docker container?
Here are the working server's mysql-related and time-related INI settings where the script works. I have set these in my docker container and I always get that timeout error in the same amount of time:
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
max_execution_time => 0 => 0
max_input_time => -1 => -1
default_socket_timeout => 60 => 60
Also, I am only selecting data. No inserts or updates. Another crucial point to consider is that I am able to run the queries with any MySQL client and get results, leading me to believe that the issue is how PHP is setup in the php:apache container.
Additionally, I just ran the same code from PHP running directly on my Windows host and I got back results. And so now I know that it's the Docker container....