0

I'm working on a one-time PHP (5.2.6) script that migrates several million of MySQL (5.0.45) database rows to another format in another table while keeping (a lot) of relevant data in memory for incremental calculations. The data is calculated incrementally. (in chunks of about 1000 lines)

The script stops unexpectedly in random points without an error message. My question is- how can I find out whats the reason for the script stopping. (memory outage? timeout by MySQL etc...)

I have set_time_limit (0); so its not PHP timeout.

2
  • You're getting good suggestions. Make sure, that you're not running in safe mode though, from the set_time_limit() docs page: "This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini." php.net/set_time_limit
    – artlung
    Jun 23, 2009 at 15:43
  • Thanks everyone. the solution was to add ini_set('memory_limit', '200M'); It was indeed a memory problem.
    – Nir
    Jun 24, 2009 at 10:36

5 Answers 5

2

see the log file, probably is memory

you need to add more memory in php.ini to memory_limit parameter

1

You could try turning the error reporting level (in php.ini) up really high, so it complains about more things.

My first guess would have been that you hit your execution time limit or memory limit and the script was terminated, but you covered that.

1
  • set_time_limit covers the execution time limit, but not the memory limit. It's possible the memory limit is being hit.
    – MaxVT
    Jun 23, 2009 at 15:38
1
  • Check out your PHP log file.
  • Turn on all error reporting
    • error_reporting(E_ALL | E_STRICT);
1

Have you tried running the PHP from the command line rather than via a web browser? Maybe the server has something which causes it to fall over once it reaches a certain memory usage?

In general bulk operations shouldn't be done via a web server, it's liable to make them fail part way through.

0

Thanks everyone for the help (I voted for the relevant answers). The issue was memory and setting ini_set('memory_limit', '200M'); solved it (it is a one time script)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.