Long running script freaks out
Posted: Tue Dec 13, 2011 8:56 pm
I am attempting to read a large file, about 350Mb with about 650,000 records. The load program started acting up so I am in debug mode.
I wrote a short script to simply count the records with fgetcsv, which is what the load uses. I run the script thru a browser. When I read anywhere 15,000 to 30,000 records, the counters that are being displayed go crazy, they go from 30, 000 to 700, then continue counting then they jump to 32,000, count some more then drop back to a lower number then count some more for a very long time. I clocked the counter at over 3 minutes (I got past the time out issues) there are no PHP warnings.
Now the interesting part. If I insert an echo "x"; statement into the read loop, the script prints out the list of x's on the screen, the counters work as expected and time drops down to about 30 seconds. Same file and no other changes to the script.
It looks like the script is being swapped in and out with the variables being reset with random data. I'm not doing anything with memory management. It also does something else strange. If, while the script is running, I make a change to the script, the new script is sometimes executed (I added an echo statement that would run at the end, and it was executed)
Does anyone have a clue why this is happening?
I wrote a short script to simply count the records with fgetcsv, which is what the load uses. I run the script thru a browser. When I read anywhere 15,000 to 30,000 records, the counters that are being displayed go crazy, they go from 30, 000 to 700, then continue counting then they jump to 32,000, count some more then drop back to a lower number then count some more for a very long time. I clocked the counter at over 3 minutes (I got past the time out issues) there are no PHP warnings.
Now the interesting part. If I insert an echo "x"; statement into the read loop, the script prints out the list of x's on the screen, the counters work as expected and time drops down to about 30 seconds. Same file and no other changes to the script.
It looks like the script is being swapped in and out with the variables being reset with random data. I'm not doing anything with memory management. It also does something else strange. If, while the script is running, I make a change to the script, the new script is sometimes executed (I added an echo statement that would run at the end, and it was executed)
Does anyone have a clue why this is happening?