Skip to content

Commit b16f3db

Browse files
authored
[dq] Don't return future with exception from ExecPlan call (YQL-17677) (#1374)
1 parent ccbe144 commit b16f3db

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ydb/library/yql/providers/dq/provider/yql_dq_gateway.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,24 @@ class TDqGatewayImpl: public std::enable_shared_from_this<TDqGatewayImpl> {
526526
std::shared_ptr<TDqGatewaySession> session;
527527
with_lock(Mutex) {
528528
auto it = Sessions.find(sessionId);
529-
if (it == Sessions.end()) {
530-
YQL_CLOG(ERROR, ProviderDq) << "Session was closed: " << sessionId;
531-
return MakeErrorFuture<TResult>(std::make_exception_ptr(std::runtime_error("Session was closed")));
529+
if (it != Sessions.end()) {
530+
session = it->second;
532531
}
533-
session = it->second;
534532
}
535-
return session->ExecutePlan(std::move(plan), columns, secureParams, graphParams, settings, progressWriter, modulesMapping, discard);
533+
if (!session) {
534+
YQL_CLOG(ERROR, ProviderDq) << "Session was closed: " << sessionId;
535+
return MakeFuture(NCommon::ResultFromException<TResult>(yexception() << "Session was closed"));
536+
}
537+
return session->ExecutePlan(std::move(plan), columns, secureParams, graphParams, settings, progressWriter, modulesMapping, discard)
538+
.Apply([](const TFuture<TResult>& f) {
539+
try {
540+
f.TryRethrow();
541+
} catch (const std::exception& e) {
542+
YQL_CLOG(ERROR, ProviderDq) << e.what();
543+
return MakeFuture(NCommon::ResultFromException<TResult>(e));
544+
}
545+
return f;
546+
});
536547
}
537548

538549
private:

0 commit comments

Comments
 (0)