Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ public void close()
if (process != null && process.isAlive()) {
process.destroy();
try {
// For native process it takes 10s to initiate SHUTDOWN. The task cleanup interval is 60s. To be sure task cleanup is run at least once we just roughly double the
// wait time.
process.waitFor(120, TimeUnit.SECONDS);
// This 1 sec is arbitrary. Ideally, we do not need to be give any heads up
// to CPP process on presto-on-spark native, because the resources
// are reclaimed by the container manager.
// For localmode, we still want to provide an opportunity for
// graceful termination as there is no resource/container manager.
process.waitFor(1, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,19 @@ private void execute(IPrestoSparkQueryExecutionFactory queryExecutionFactory, Pr
@Override
public void close()
{
// Shutdown the driver Airlift application
driverPrestoSparkService.close();

// If we are in localMode, the executor spawns the Executor Airlift application
// (which is long-running and holds onto resources) on the same JVM.
//
// On query completion, the SparkContext shutdown calls the Driver Airlift
// application shutdown, but it has no hook to call Executor Airlift application
// shutdown. So the query hangs forever.
//
// This code, prevents this hanging state by explicitly calling the
// Executor Airlift application shutdown.
DistributionBasedPrestoSparkTaskExecutorFactoryProvider.close();
}

private static IPrestoSparkServiceFactory createServiceFactory(File directory)
Expand Down Expand Up @@ -324,5 +336,12 @@ public static void checkEquals(String name, Object first, Object second)
throw new IllegalStateException(format("%s is different: %s != %s", name, first, second));
}
}

public static synchronized void close()
{
if (service != null) {
service.close();
}
}
}
}