客户端断开连接后,mongodb应该终止map-reduce进程

I connect to mongodb with php's driver and make a map-reduce command. Sometimes the mapreduce takes a long time and this is not a problem for me, at least for now.

The problem is that when I kill the php process, the map-reduce continues to work. I want that when a client disconnects, its all processes should stop too. Because the results of the processes are no longer necessary.

The problem is that when I kill the php process, the map-reduce continues to work.

How can MongoDB know the PHP process was killed, all it sees is a command on a connection came in and that connection is still being used.

This is one reason why you SHOULDN'T run Map Reduce inline to your application and why it is recommended not to.

This same problem applies to web servers when in connection to browsers, a PHP process will conitnue running when a browser is closed.