Report silent pregen failures instead of swallowing them

Empty catch (Throwable ignored) blocks in pregen hid failed capability probes, a stranded plugin chunk ticket and failed mantle cleanup. Probes now log their name and cause at debug through PregenDiagnostics, and real losses go through IrisLogging.reportError. The chunk load failure trace is emitted before the metrics snapshot so a failing snapshot cannot silence it.

Upstream: e030ac3be
This commit is contained in:
piexel committed 2026-11-10 01:29:00 +01:00
1 parent ae60b14402
commit 19129c2eb8
6 files changed
+290 -12

No files matched your search

@@ -0,0 +1,43 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.pregenerator;
import art.arcane.iris.spi.IrisLogging;
public final class PregenDiagnostics {
private PregenDiagnostics() {
}
public static void probeFailed(String probe, Throwable failure) {
IrisLogging.debug("Pregen probe " + describeProbe(probe) + " failed: " + describeFailure(failure));
}
public static String describeProbe(String probe) {
return probe == null || probe.isBlank() ? "unnamed" : probe;
}
public static String describeFailure(Throwable failure) {
if (failure == null) {
return "no throwable reported";
}
String message = failure.getMessage();
return message == null ? failure.getClass().getName() : failure.getClass().getName() + ": " + message;
}
}
@@ -170,7 +170,8 @@ public final class PregenMantleBackpressure {
try {
return cancelled.getAsBoolean();
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("pregen cancellation state", e);
return false;
}
}
@@ -178,7 +179,8 @@ public final class PregenMantleBackpressure {
private Mantle resolveMantle() {
try {
return mantleSupplier.get();
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("mantle handle for backpressure", e);
return null;
}
}
@@ -22,6 +22,7 @@ import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.core.IrisPaperLikeBackendMode;
import art.arcane.iris.core.IrisRuntimeSchedulerMode;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.pregenerator.PregenDiagnostics;
import art.arcane.iris.core.pregenerator.PregenListener;
import art.arcane.iris.core.pregenerator.PregenMantleBackpressure;
import art.arcane.iris.core.pregenerator.PregeneratorMethod;
@@ -214,7 +215,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
if (coreThreads instanceof Thread[] threadsArray) {
return threadsArray.length;
}
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("moonrise worker pool size", e);
}
return -1;
@@ -240,7 +242,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
int resolved = radius > 0 ? Math.max(1, (int) Math.ceil(radius / 32.0)) : 2;
evictionWindowRegions = resolved;
return resolved;
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("mantle radius for eviction window", e);
return 2;
}
}
@@ -409,7 +412,9 @@ public class AsyncPregenMethod implements PregeneratorMethod {
private void unloadChunkSafely(int cx, int cz) {
try {
world.removePluginChunkTicket(cx, cz, BukkitPlatform.plugin());
} catch (Throwable ignored) {
} catch (Throwable e) {
IrisLogging.reportError("Async pregen could not release the plugin chunk ticket at " + cx + "," + cz
+ " in world " + world.getName() + "; the chunk stays pinned in memory.", e);
}
try {
@@ -490,11 +495,12 @@ public class AsyncPregenMethod implements PregeneratorMethod {
}
private Chunk onChunkFutureFailure(int x, int z, Throwable throwable) {
try {
IrisLogging.warn("Failed async pregen chunk load at " + x + "," + z + ". " + metricsSnapshot());
IrisLogging.reportError("Failed async pregen chunk load at " + x + "," + z + ".", throwable);
IrisLogging.reportError(throwable);
try {
IrisLogging.warn("Async pregen state at the failed chunk " + x + "," + z + ". " + metricsSnapshot());
} catch (Throwable e) {
PregenDiagnostics.probeFailed("pregen metrics snapshot", e);
}
return null;
@@ -780,7 +786,9 @@ public class AsyncPregenMethod implements PregeneratorMethod {
if (engine != null) {
try {
engine.getMantle().forceCleanupChunk(x, z);
} catch (Throwable ignored) {
} catch (Throwable e) {
IrisLogging.reportError("Async pregen mantle cleanup failed at chunk " + x + "," + z
+ " in world " + world.getName() + "; tectonic plates for that chunk stay resident.", e);
}
}
}
@@ -801,7 +809,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
metricsEngine = resolvedEngine;
}
return resolvedEngine;
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("engine access for world " + world.getName(), e);
return null;
}
}
@@ -1154,7 +1163,9 @@ public class AsyncPregenMethod implements PregeneratorMethod {
requestMonitoredChunkAsync(x, z)
.whenComplete((chunk, throwable) -> completeChunk(x, z, listener, chunk, throwable));
return;
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("folia direct chunk request at " + x + "," + z
+ ", falling back to a region task", e);
}
Runnable regionTask = () -> {
@@ -19,6 +19,7 @@
package art.arcane.iris.core.pregenerator.methods;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.pregenerator.PregenDiagnostics;
import art.arcane.iris.core.pregenerator.PregenListener;
import art.arcane.iris.core.pregenerator.PregeneratorMethod;
import art.arcane.iris.core.tools.IrisToolbelt;
@@ -101,7 +102,8 @@ public class MedievalPregenMethod implements PregeneratorMethod {
if (cached != null) {
cachedEngine = cached;
}
} catch (Throwable ignored) {
} catch (Throwable e) {
PregenDiagnostics.probeFailed("engine access for world " + world.getName(), e);
}
return cached;
}