Search in sources :

Example 1 with DummySpillerFactory

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);
}
Also used : DummySpillerFactory(io.trino.operator.join.JoinTestUtils.DummySpillerFactory) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) PartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory) Test(org.testng.annotations.Test)

Example 2 with DummySpillerFactory

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());
}
Also used : DummySpillerFactory(io.trino.operator.join.JoinTestUtils.DummySpillerFactory) TaskId(io.trino.execution.TaskId) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) BuildSideSetup(io.trino.operator.join.JoinTestUtils.BuildSideSetup) StageId(io.trino.execution.StageId) TaskStateMachine(io.trino.execution.TaskStateMachine) Test(org.testng.annotations.Test)

Aggregations

DummySpillerFactory (io.trino.operator.join.JoinTestUtils.DummySpillerFactory)2 Test (org.testng.annotations.Test)2 RowPagesBuilder (io.trino.RowPagesBuilder)1 StageId (io.trino.execution.StageId)1 TaskId (io.trino.execution.TaskId)1 TaskStateMachine (io.trino.execution.TaskStateMachine)1 TaskContext (io.trino.operator.TaskContext)1 BuildSideSetup (io.trino.operator.join.JoinTestUtils.BuildSideSetup)1 GenericPartitioningSpillerFactory (io.trino.spiller.GenericPartitioningSpillerFactory)1 PartitioningSpillerFactory (io.trino.spiller.PartitioningSpillerFactory)1 TestingTaskContext (io.trino.testing.TestingTaskContext)1