globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 231 forks source link

dbtest: mongod process not killed if spawned from a shim (e.g. installed with scoop) #328

Closed ogerardin closed 5 years ago

ogerardin commented 5 years ago

When mongod is installed using scoop, a shallow executable called a "shim" is created in the path (usually in %USERPROFILE%\scoop\shims). The actual mongod.exe lies somewhere else (normally %USERPROFILE%\scoop\apps\mongodb\current). When you launch mongod from the command line, the shim launches the actual mongod as a sub-process. The same happens when dbtest launches mongod, but when it tries to stop the server only the shim gets terminated, the actual server process stays alive and is adopted by userinit.


What version of MongoDB are you using (mongod --version)?

db version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
allocator: tcmalloc
modules: none
build environment:
    distmod: 2008plus-ssl
    distarch: x86_64
    target_arch: x86_64

What version of Go are you using (go version)?

go version go1.11.5 windows/amd64

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

Install mongo with scoop (scoop install mongodb) Run TestStop in dbserver_test.go Produces error: "Stop did not stop the server"

Fix (tested): replace dbs.server.Process.Signal(os.Kill) with psutil.TerminateTree(dbs.server.Process.Pid, int(syscall.SIGKILL)) in method Stop

Can you reproduce the issue on the latest development branch?

yes

maitesin commented 5 years ago

Hi @ogerardin

Can you provide some code to reproduce this behaviour?

Best regards, Oscar

ogerardin commented 5 years ago

As I wrote, running TestStop in dbserver_test.go will produces error: "Stop did not stop the server".

domodwyer commented 5 years ago

Hey @ogerardin

I think this is probably an issue with scoop not propagating the signal to the child mongod process if scoop itself is stopped.

Dom

ogerardin commented 5 years ago

You're certainly right, but I think killing the process tree is safer in all cases. I'll see if I can open an issue with scoop.