简体   繁体   中英

Terminating (graciously) MonetDB process in R

I'm using MonetDB on a variety of platform (eg OS X and Linux Centos) with a shiny application.

It is difficult to disconnect the db all the times, so currently my approach is to terminate the shiny app without disconnecting the db.

This means that the shiny app before accessing the data tries to stop any "old" process with:

monetdb.server.stop(pid)

From the source of the command I understand that it basically kills the process associated to the pid provided (which means among other things that the user running the app must have access to the kill function).

This works OK some of the times, but sometimes when I try to start MonetDB again, I get

!FATAL: GDKlockHome: Database lock '.gdk_lock' denied

Warning in socketConnection(host = host, port = port, blocking = TRUE, open = "r+b",  :
  localhost:50000 cannot be opened
Error in socketConnection(host = host, port = port, blocking = TRUE, open = "r+b",  : 
  cannot open the connection

Is there a way to avoid this error (without forcibly disconnecting the database all the time I use it in shiny)?

It can indeed take a couple of seconds for MonetDB to shut down. If a new process is started on the same dbfarm directory in the meantime, you will get the !FATAL: GDKlockHome: Database lock '.gdk_lock' denied error. I'm considering adding a wait parameter to monetdb.server.stop .

So in the meantime, waiting a bit before the server is started again is a good idea. Otherwise, consider using monetdbd to manage your MonetDB servers.

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