Contain failed placements and let engine failures end the chunk

Placement code caught Throwable and logged it, so a closed session, a stopping executor or an OOM inside a placement left a half-built chunk that was then persisted. A classifier in the api separates those failures from content failures: the first are rethrown, the second are skipped with one rate-limited warning per kind, subject and failure type.

Upstream: 54f3595ba ebe4aa1e4 7b38f7584 f4f7e92a4 8cf9e01d9
This commit is contained in:
piexel committed 2026-11-10 01:04:37 +01:00
1 parent fc5c6ce0ab
commit de1c6e887f
13 files changed
+318 -22

No files matched your search

@@ -1,6 +1,8 @@
package art.arcane.iris.engine.framework;
public class GenerationSessionException extends WrongEngineBroException {
import com.volmit.generation.EngineFailure;
public class GenerationSessionException extends WrongEngineBroException implements EngineFailure {
private final boolean expectedTeardown;
public GenerationSessionException(String message) {
@@ -24,6 +24,7 @@ import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.matter.TileWrapper;
import com.google.common.collect.ImmutableList;
import com.volmit.generation.GenerationFailures;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.link.Identifier;
import art.arcane.iris.core.tools.WorldMaintenance;
@@ -963,6 +964,7 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
try {
setData(pos.getX(), pos.getY(), pos.getZ(), data);
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
// Reached per position while an object writes past the edge of the writer window, which is
// how a large object is clipped. Nothing here is actionable from outside the engine.
IrisLogging.debug("No set? " + data.toString() + " for " + pos.toString());
@@ -13,6 +13,7 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -20,6 +21,7 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.Mockito.mock;
@@ -83,6 +85,27 @@ public class DecoratorCoreTest {
assertNull(result);
}
@Test
public void pickDecorator_contentFailure_skipsThatDecorator() {
ResolvedDecorator broken = mock(ResolvedDecorator.class);
when(broken.passesChanceGate(anyDouble(), anyDouble())).thenThrow(new IllegalArgumentException("malformed decorator"));
ResolvedDecorator healthy = mock(ResolvedDecorator.class);
when(healthy.passesChanceGate(anyDouble(), anyDouble())).thenReturn(true);
ResolvedDecorator result = DecoratorCore.pickDecorator(new ResolvedDecorator[]{broken, healthy}, new RNG(2L), 0.0, 0.0, ModuleLogs.discarding());
assertSame(healthy, result);
}
@Test
public void pickDecorator_engineFailure_endsTheChunk() {
ResolvedDecorator closed = mock(ResolvedDecorator.class);
RejectedExecutionException failure = new RejectedExecutionException("pool shut down");
when(closed.passesChanceGate(anyDouble(), anyDouble())).thenThrow(failure);
assertSame(failure, assertThrows(RejectedExecutionException.class, () ->
DecoratorCore.pickDecorator(new ResolvedDecorator[]{closed}, new RNG(2L), 0.0, 0.0, ModuleLogs.discarding())));
}
@Test
public void pickDecorator_singleCandidate_alwaysReturnsThat() {
ResolvedDecorator d = mock(ResolvedDecorator.class);