简体   繁体   中英

kill long running MySQL process on window close event from PHP

We have a long running SQL in a PHP process. Sometimes, user close the window and the SQL still keeps running in background , killing the performance of server.

Can SQL be stopped as soon as PHP process is killed on closing the window?

I think I will need to handle window close event in browser and do some exception handling in php script on occurrence of the event ..

You have 3 independant 'process' here, browser, php and sql.

Php won't know it the browser has been closed and therefore can't kill the sql process. If the query is taking so long then the php will timeout anyway. This is usually set to 30 seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM