Drained pregen before shutdown

- Server shutdown advances native chunk tasks while waiting for pregeneration
- Native world close owns chunk saves during server shutdown
- Pending plugin flushes stop waiting when native shutdown begins
- Late eviction completion cannot schedule another shutdown flush
- Regression tests cover owner waits and shutdown save ownership
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-06 18:20:26 -04:00
1 parent 319f8aed47
commit 083e689864
6 files changed
+420 -4

No files matched your search

@@ -1037,7 +1037,16 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
}
try {
PregeneratorJob.shutdownAndWait(SERVER_STOP_PREGEN_TIMEOUT_MILLIS);
if (J.isFolia()) {
PregeneratorJob.shutdownAndWait(SERVER_STOP_PREGEN_TIMEOUT_MILLIS);
} else {
List<World> worlds = Bukkit.getWorlds();
PregeneratorJob.shutdownAndWait(SERVER_STOP_PREGEN_TIMEOUT_MILLIS, () -> {
for (World world : worlds) {
INMS.get().pollChunkTask(world);
}
});
}
} catch (Throwable e) {
Iris.reportError("Failed to quiesce the Iris pregenerator before server shutdown.", e);
}
@@ -52,7 +52,10 @@ public class BukkitEngineLifecycleContractTest {
String waitedShutdown = method(jobSource,
"private static boolean shutdownAndWait(PregeneratorJob inst, long timeoutMs)");
assertBefore(waitedShutdown, "inst.requestStop()", "inst.worker.join(");
assertTrue(waitedShutdown.contains("inst.worker.isAlive()"));
assertBefore(waitedShutdown, "inst.worker.join(", "finishShutdown(inst, timeoutMs)");
String finishedShutdown = method(jobSource,
"private static boolean finishShutdown(PregeneratorJob inst, long timeoutMs)");
assertBefore(finishedShutdown, "inst.worker.isAlive()", "instance.compareAndSet(inst, null)");
String hooksSource = Files.readString(Path.of(System.getProperty("iris.bukkitEnginePlatformHooksSource")));
String hookShutdown = method(hooksSource, "public void shutdownPregenerator(Engine engine)");