Once the investigation record multithreading problem

Recently encountered an anomaly export pdf report file does not exist, after looking at the code and found to export pdf subject to four steps: generating a temporary pdf, fill pdf content downloaded to the client, delete pdf. Reported abnormal code file does not exist to locate downloaded to the client this step. Thus, there is a conjecture: multithreading issues raised.

This led to speculation that abnormal behavior is specific A and B must export the pdf, but B than A little later, the results derived A normal, downloaded to the client B in this step, I found the pdf file has been exported A's thread deleted, so they reported abnormal file does not exist.

In order to confirm this conjecture, using jmeter testing tools simulate six users simultaneously requested 100 times, according to the log printing, this really is the case. Log shots are as follows:

 

 

487 can be seen in this thread from the log files are deleted, go to download 485 will be reported when the file is not found exception

The idea is to solve the problem of critical resources into non-critical resources, so we started practice is to add a time stamp on the file name, and later found to have the same name will become a phenomenon that is a critical resource. Subsequent addition of a UUID (unique serial number on a space-time machine), the same name will not, i.e. non-critical resource. So far the problem is solved.

Guess you like

Origin www.cnblogs.com/yelele/p/12141773.html