use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.
the class SqlQueryExecution method createResumeScheduler.
private SqlQueryScheduler createResumeScheduler(PlanRoot plan, OutputBuffers rootOutputBuffers) {
String resumeMessage = "Query encountered failures. Recovering using the distributed-snapshot feature.";
warningCollector.add(new PrestoWarning(StandardWarningCode.SNAPSHOT_RECOVERY, resumeMessage));
// Check if there is a snapshot we can restore to, or restart from beginning,
// and update marker split sources so they know where to resume from.
// This MUST be done BEFORE creating the new scheduler, because it resets the snapshotManager internal states.
OptionalLong snapshotId = snapshotManager.getResumeSnapshotId();
MarkerAnnouncer announcer = splitManager.getMarkerAnnouncer(stateMachine.getSession());
announcer.resumeSnapshot(snapshotId.orElse(0));
// Clear any temporary content that's not part of the snapshot
resetOutputData(plan, snapshotId);
// Create a new scheduler, to schedule new stages and tasks
DistributedExecutionPlanner distributedExecutionPlanner = new DistributedExecutionPlanner(splitManager, metadata);
StageExecutionPlan executionPlan = distributedExecutionPlanner.plan(plan.getRoot(), stateMachine.getSession(), RESUME, snapshotId.isPresent() ? snapshotId.getAsLong() : null, announcer.currentSnapshotId());
// build the stage execution objects (this doesn't schedule execution)
return createSqlQueryScheduler(stateMachine, locationFactory, executionPlan, nodePartitioningManager, nodeScheduler, remoteTaskFactory, stateMachine.getSession(), plan.isSummarizeTaskInfos(), scheduleSplitBatchSize, queryExecutor, schedulerExecutor, failureDetector, rootOutputBuffers, nodeTaskMap, executionPolicy, schedulerStats, dynamicFilterService, heuristicIndexerManager, snapshotManager, // Require same number of tasks to be scheduled, but do not require it if starting from beginning
snapshotId.isPresent() ? queryScheduler.get().getStageTaskCounts() : null);
}
use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.
the class TestDefaultWarningCollector method testMaxWarnings.
@Test
public void testMaxWarnings() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(2));
warningCollector.add(new PrestoWarning(new WarningCode(1, "1"), "warning 1"));
warningCollector.add(new PrestoWarning(new WarningCode(2, "2"), "warning 2"));
warningCollector.add(new PrestoWarning(new WarningCode(3, "3"), "warning 3"));
assertEquals(warningCollector.getWarnings().size(), 2);
}
use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.
the class TestJdbcWarnings method testSqlWarning.
@Test
public void testSqlWarning() {
ImmutableList.Builder<PrestoWarning> builder = ImmutableList.builder();
for (int i = 0; i < 3; i++) {
builder.add(new PrestoWarning(new WarningCode(i, "CODE_" + i), "warning message " + i));
}
List<PrestoWarning> warnings = builder.build();
SQLWarning warning = fromPrestoWarnings(warnings);
assertEquals(Iterators.size(warning.iterator()), warnings.size());
assertWarningsEqual(warning, toPrestoSqlWarning(warnings.get(0)));
assertWarningsEqual(warning.getNextWarning(), toPrestoSqlWarning(warnings.get(1)));
assertWarningsEqual(warning.getNextWarning().getNextWarning(), toPrestoSqlWarning(warnings.get(2)));
}
use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.
the class TestJdbcWarnings method testStatementWarnings.
@Test
public void testStatementWarnings() throws SQLException {
assertFalse(statement.execute("CREATE SCHEMA blackhole.test_schema"));
SQLWarning warning = statement.getWarnings();
assertNotNull(warning);
TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS);
TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
assertStartsWithExpectedWarnings(warning, fromPrestoWarnings(expectedWarnings));
statement.clearWarnings();
assertNull(statement.getWarnings());
}
use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.
the class TestJdbcWarnings method testExecuteQueryWarnings.
@Test
public void testExecuteQueryWarnings() throws SQLException {
try (ResultSet rs = statement.executeQuery("SELECT a FROM (VALUES 1, 2, 3) t(a)")) {
assertNull(statement.getConnection().getWarnings());
assertNull(statement.getWarnings());
assertNull(rs.getWarnings());
Set<WarningEntry> currentWarnings = new HashSet<>();
while (rs.next()) {
assertWarnings(rs.getWarnings(), currentWarnings);
}
TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS).setAddWarnings(true);
TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
for (PrestoWarning prestoWarning : expectedWarnings) {
assertTrue(currentWarnings.contains(new WarningEntry(toPrestoSqlWarning(prestoWarning))));
}
}
}
Aggregations