fix(g1): propagate incomplete shutdown exit code and stop console after quit

This commit is contained in:
OpenGenesis (MPL 2.0) committed 2026-11-07 15:04:17 +01:00
1 parent d620ad8843
commit 3f95e4f08a
9 files changed
+49 -4

No files matched your search

+3
View File
@@ -8,6 +8,9 @@ on:
- 'OpenSim/Region/Framework/Scenes/SceneManager.cs'
- 'OpenSim/Region/Framework/Scenes/Scene.cs'
- 'OpenSim/Region/Application/OpenSimBase.cs'
- 'OpenSim/Region/Application/Application.cs'
- 'OpenSim/Framework/Servers/ServerBase.cs'
- 'OpenSim/Framework/Servers/BaseOpenSimServer.cs'
- 'OpenSim/Region/Application/OpenSimBackground.cs'
- 'tools/ci/Net10ShutdownRegression/**'
- 'tools/ci/verify_net10_shutdown.py'
@@ -57,6 +57,12 @@ namespace OpenSim.Framework.Servers
/// </summary>
public bool SuppressExit { get; set; }
/// <summary>
/// Allows region hosts to report incomplete persistence and failed cleanup
/// as a nonzero exit to systemd, instead of always signaling success.
/// </summary>
protected int ShutdownExitCode { get; set; }
/// <summary>
/// This will control a periodic log printout of the current 'show stats' (if they are active) for this
/// server.
@@ -145,7 +151,7 @@ namespace OpenSim.Framework.Servers
m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
if (!SuppressExit)
Environment.Exit(0);
Environment.Exit(ShutdownExitCode);
}
/// <summary>
+8
View File
@@ -51,6 +51,13 @@ namespace OpenSim.Framework.Servers
public IConfigSource Config { get; protected set; }
private int m_shutdownRequested;
/// <summary>
/// Used by the host console to stop prompting after quit/shutdown.
/// </summary>
public bool ShutdownRequested => Volatile.Read(ref m_shutdownRequested) != 0;
/// <summary>
/// Console to be used for any command line output. Can be null, in which case there should be no output.
/// </summary>
@@ -977,6 +984,7 @@ namespace OpenSim.Framework.Servers
public virtual void Shutdown()
{
Interlocked.Exchange(ref m_shutdownRequested, 1);
m_serverStatsCollector.Close();
ShutdownSpecific();
}
+1 -1
View File
@@ -303,7 +303,7 @@ namespace OpenSim
m_sim.Startup();
while (true)
while (!m_sim.ShutdownRequested)
{
try
{
+4 -1
View File
@@ -1006,10 +1006,12 @@ namespace OpenSim
Config?.Configs["OGLShutdown"]?.GetInt("RegionCloseTimeoutSeconds", 180) ?? 180, 0, 3600);
try
{
SceneManager.Close(regionCloseTimeoutSeconds);
if (!SceneManager.Close(regionCloseTimeoutSeconds))
ShutdownExitCode = 1;
}
catch (Exception e)
{
ShutdownExitCode = 1;
m_log.Error("[OGL SHUTDOWN]: Scene manager failed; attempting plugin cleanup regardless.", e);
}
@@ -1018,6 +1020,7 @@ namespace OpenSim
try { plugin.Dispose(); }
catch (Exception e)
{
ShutdownExitCode = 1;
m_log.Error("[OGL SHUTDOWN]: Failed to dispose plugin " + plugin.GetType().FullName, e);
}
}
@@ -148,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes
/// continues closing on a background thread and its unsaved state may be lost
/// when the process exits. Use systemd's stop timeout as a second watchdog.
/// </summary>
public void Close(int regionCloseTimeoutSeconds = 0)
public bool Close(int regionCloseTimeoutSeconds = 0)
{
List<Scene> localScenes;
lock (m_localScenes)
@@ -207,6 +207,8 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("[OGL SHUTDOWN]: {0} of {1} region close operations failed or timed out; check backups before restarting.", failed, localScenes.Count);
else
m_log.InfoFormat("[OGL SHUTDOWN]: All {0} region close operations completed.", localScenes.Count);
return failed == 0;
}
public void Close(Scene cscene)
+11
View File
@@ -52,3 +52,14 @@ still needs an in-world high-churn stress test.
base shutdown completed. The completion event is now signalled from a
`finally` block **after** application cleanup, preventing the main
thread from treating an in-progress shutdown as completed.
## Shutdown service exit status and console loop
`SceneManager.Close(int)` now reports a boolean result. A scene timeout,
exception or plugin-disposal failure marks the simulator's exit status nonzero
instead of falsely reporting success to systemd. This does not recover unsaved
data; operators must inspect failed region names before restarting.
The console command loop stops requesting new prompts after a shutdown
request. The normal process still exits through the inherited server shutdown
handler after cleanup.
@@ -53,3 +53,6 @@ ack.Remove(123);
ack.Clear();
Assert(ack.Count() == 0, "ACK queue tolerates late callback and repeated close");
Console.WriteLine("PASS: .NET 10 OGKF serialization, legacy preservation and UDP teardown regression");
Assert(typeof(SceneManager).GetMethod("Close", new[] { typeof(int) })!.ReturnType == typeof(bool),
"region shutdown reports success/failure");
+9
View File
@@ -15,6 +15,15 @@ assert "IsBackground = true" in scenes
assert "scene.Close();" in scenes
assert "plugin.Dispose()" in base
assert "SceneManager.Close(regionCloseTimeoutSeconds)" in base
assert "if (!SceneManager.Close(regionCloseTimeoutSeconds))" in base
assert "ShutdownExitCode = 1;" in base
assert "return failed == 0;" in scenes
server = (root / "OpenSim/Framework/Servers/BaseOpenSimServer.cs").read_text()
assert "Environment.Exit(ShutdownExitCode)" in server
host = (root / "OpenSim/Framework/Servers/ServerBase.cs").read_text()
app = (root / "OpenSim/Region/Application/Application.cs").read_text()
assert "public bool ShutdownRequested" in host
assert "while (!m_sim.ShutdownRequested)" in app
background = (root / "OpenSim/Region/Application/OpenSimBackground.cs").read_text()
shutdown = background.split("public override void Shutdown()", 1)[1]
assert shutdown.index("base.Shutdown();") < shutdown.index("WorldHasComeToAnEnd.Set();")