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

@@ -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);