use of io.trino.operator.join.JoinTestUtils.DummySpillerFactory in project trino by trinodb.
the class TestHashJoinOperator method testInnerJoinWithFailingSpill.
@Test(dataProvider = "joinWithFailingSpillValues")
public void testInnerJoinWithFailingSpill(boolean probeHashEnabled, List<WhenSpill> whenSpill, WhenSpillFails whenSpillFails) {
DummySpillerFactory buildSpillerFactory = new DummySpillerFactory();
DummySpillerFactory joinSpillerFactory = new DummySpillerFactory();
PartitioningSpillerFactory partitioningSpillerFactory = new GenericPartitioningSpillerFactory(joinSpillerFactory);
String expectedMessage;
switch(whenSpillFails) {
case SPILL_BUILD:
buildSpillerFactory.failSpill();
expectedMessage = "Spill failed";
break;
case SPILL_JOIN:
joinSpillerFactory.failSpill();
expectedMessage = "Spill failed";
break;
case UNSPILL_BUILD:
buildSpillerFactory.failUnspill();
expectedMessage = "Unspill failed";
break;
case UNSPILL_JOIN:
joinSpillerFactory.failUnspill();
expectedMessage = "Unspill failed";
break;
default:
throw new IllegalArgumentException(format("Unsupported option: %s", whenSpillFails));
}
assertThatThrownBy(() -> innerJoinWithSpill(probeHashEnabled, whenSpill, buildSpillerFactory, partitioningSpillerFactory)).isInstanceOf(RuntimeException.class).hasMessage(expectedMessage);
}
use of io.trino.operator.join.JoinTestUtils.DummySpillerFactory in project trino by trinodb.
the class TestHashJoinOperator method testBuildGracefulSpill.
@Test(timeOut = 30_000)
public void testBuildGracefulSpill() throws Exception {
TaskStateMachine taskStateMachine = new TaskStateMachine(new TaskId(new StageId("query", 0), 0, 0), executor);
TaskContext taskContext = TestingTaskContext.createTaskContext(executor, scheduledExecutor, TEST_SESSION, taskStateMachine);
// build factory
RowPagesBuilder buildPages = rowPagesBuilder(false, Ints.asList(0), ImmutableList.of(VARCHAR, BIGINT)).addSequencePage(4, 20, 200);
DummySpillerFactory buildSpillerFactory = new DummySpillerFactory();
BuildSideSetup buildSideSetup = setupBuildSide(nodePartitioningManager, true, taskContext, buildPages, Optional.empty(), true, buildSpillerFactory);
instantiateBuildDrivers(buildSideSetup, taskContext);
JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = buildSideSetup.getLookupSourceFactoryManager();
PartitionedLookupSourceFactory lookupSourceFactory = lookupSourceFactoryManager.getJoinBridge(Lifespan.taskWide());
// finish probe before any build partition is spilled
lookupSourceFactory.finishProbeOperator(OptionalInt.of(1));
// spill build partition after probe is finished
HashBuilderOperator hashBuilderOperator = buildSideSetup.getBuildOperators().get(0);
hashBuilderOperator.startMemoryRevoke().get();
hashBuilderOperator.finishMemoryRevoke();
hashBuilderOperator.finish();
// hash builder operator should not deadlock waiting for spilled lookup source to be disposed
hashBuilderOperator.isBlocked().get();
lookupSourceFactory.destroy();
assertTrue(hashBuilderOperator.isFinished());
}
Aggregations