Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Feb 2019 10:43:23 -0700
From:      James Gritton <jamie@freebsd.org>
To:        jail@freebsd.org
Subject:   Re: jails which take a long time to shutdown
Message-ID:  <62ba257cb405e566d45b54a760017f12@freebsd.org>
In-Reply-To: <08D0C738-8D03-4618-BC8C-26B076293493@langille.org>
References:  <08D0C738-8D03-4618-BC8C-26B076293493@langille.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2019-02-06 08:47, Dan Langille wrote:
> Michael,
> 
> Something came to mind with your recent post about exit codes.
> 
> What if a jail takes minutes to shutdown?  Will it be shutdown 
> properly?
> 
> I ask because I routinely have a jail which when restarted has a
> corrupted mongodb database.
> 
> I have not tracked down the issue, but I know it takes a while to 
> shutdown.

There are two jail parameters that work will effect that.  
"exec.timeout" sets a limit that jail(8) will wait for a command such as 
rc.shutdown to complete.  Setting this may cause your jail to fail to 
stop - at least as far as jail(8) knows.  The command will still be 
running, and rc.shutdown may or may not eventually complete, and then 
the jail may then go away on its own if "persist" isn't set.  Not 
setting it will make jail(8) sit and wait for an indefinite time.

"stop.timeout" sets a limit that jail will wait after successful 
completion of the stop scripts, between sending everything a SIGTERM and 
removing the jail outright (which will send then a SIGKILL from the 
kernel).  It has a default of ten seconds, but may be set to zero in 
which case it's straight to removal and SIGKILL.

In addition to these, there's rc.shutdown's $rcshutdown_timeout.  It 
would make sense to set exec.time to at least this long (default 90 
seconds) if you use it at all.

So if your desire is to protect database integrity over getting a known 
shutdown time, keep exec.timeout unset and change $rcshutdown_timeout to 
"".  Then jail -r should patiently wait.

- Jamie



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62ba257cb405e566d45b54a760017f12>