Home  >  Article  >  Backend Development  >  How to solve the File size limit exceeded error_PHP tutorial

How to solve the File size limit exceeded error_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:06:201234browse

I encountered a problem yesterday. I used the Yii framework to write a php script to export more than 1 million data in the db and run it successfully.

But when running to the 490,000th item, the script terminated and prompted the error "File size limit exceeded", so I googled it and found that the size of a certain file exceeded the system limit. The author's first reaction was that the log file was full? ? ? I quickly checked the log and found that it was only a few dozen K!!! So where is this "big file"?

Starting the analysis, it cannot be a problem with the Yii framework. This is an abnormal problem of the Linux operating system and the framework is dull, nor is it the size of the log file. I carefully checked the files under all the set log paths. They are all small and can be ignored. Even if Yii debug is turned off, the same problem occurs.

Then change the idea, re-run the script, run the script again, and find that the dead time is very regular. It all hangs up when there are 450,000 records, one is no more and one is less. I begin to suspect that it is related to the process. Decided to view the io affected by the script process.

1. First get the of the script process;

2. Use the lsof command to check the io status of this pid: lsof -p

A suspected file data0/xdebug/cachegrind.out. was found. As the script was executed, the size of the xdebug file also increased. Finally, as expected, it died! The file size at this time is: 2147483647! !

Haha, such a familiar number, 2^31 -1! !

It seems that the problem has been found. When the script is executed, xdebug also writes and records the log of the script process. When the file size exceeds the file size that the system can support, it hangs as expected.

ok, turn off xdebug and re-run the script. More than one million records have been successfully run. Done.

ps: The server I am using is a 32-bit system, and in a 32-bit operating system, because it is binary, the maximum data it can store is 1111111111111111111111111111111.

Because of this, the decimal notation reflected in other visual systems is 2147483647.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327621.htmlTechArticleI encountered a problem yesterday. I used the Yii framework to write a php script to export more than 1 million data in the db and run it. ,success. But when running to the 490,000th item, the script terminates, prompting the error "...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn