Pump native chunk tasks while server stop waits for pregen

On Paper only the server thread advances chunk tasks, so a stop that blocks on a running pregen can wait forever. Stop now polls the native chunk queue while joining the pregen worker, and pregen skips eviction and flush scheduling once the server is stopping.

Upstream: 083e68986
This commit is contained in:
piexel committed 2026-11-10 01:27:07 +01:00
1 parent e87e6d9fae
commit ae60b14402
8 files changed
+226 -3

No files matched your search

@@ -993,7 +993,16 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
StudioBridges.closeAll();
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.worker.interrupt()", "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)");