Fix Ops Studio issue 97 where query connection is dropped (#549)

- Fixes https://github.com/Microsoft/sqlopsstudio/issues/97.
- This should fix the bulk of the issues reported by users since it's the 1st use of this connection in the query code path.
- Implemented the fix in the connection service. This will always open a connection when calling `GetOrOpenConnection`. I cannot see a reason why the connection returned from this should ever be closed.
- resolve issues in both this code path and the edit data code path since both use this method.
This commit is contained in:
Kevin Cunnane
2017-11-21 14:46:20 -08:00
committed by GitHub
parent c512d53caa
commit 42ee96f99f
5 changed files with 105 additions and 39 deletions

View File

@@ -141,8 +141,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
else
{
ScriptingScriptOperation operation = new ScriptingScriptOperation(parameters);
operation.PlanNotification += (sender, e) => requestContext.SendEvent(ScriptingPlanNotificationEvent.Type, e);
operation.ProgressNotification += (sender, e) => requestContext.SendEvent(ScriptingProgressNotificationEvent.Type, e);
operation.PlanNotification += (sender, e) => requestContext.SendEvent(ScriptingPlanNotificationEvent.Type, e).Wait();
operation.ProgressNotification += (sender, e) => requestContext.SendEvent(ScriptingProgressNotificationEvent.Type, e).Wait();
operation.CompleteNotification += (sender, e) => this.SendScriptingCompleteEvent(requestContext, ScriptingCompleteEvent.Type, e, operation, parameters.ScriptDestination);
RunTask(requestContext, operation);
@@ -267,11 +267,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
}
// send script result to client
requestContext.SendResult(new ScriptingResult { Script = script });
requestContext.SendResult(new ScriptingResult { Script = script }).Wait();
}
catch (Exception e)
{
requestContext.SendError(e);
requestContext.SendError(e).Wait();
}
return null;
@@ -283,7 +283,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
/// </summary>
private void RunTask<T>(RequestContext<T> context, ScriptingOperation operation)
{
Task.Run(() =>
Task.Run(async () =>
{
try
{
@@ -292,14 +292,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
}
catch (Exception e)
{
context.SendError(e);
await context.SendError(e);
}
finally
{
ScriptingOperation temp;
this.ActiveOperations.TryRemove(operation.OperationId, out temp);
}
}).ContinueWithOnFaulted(null);
}).ContinueWithOnFaulted(async t => await context.SendError(t.Exception));
}
/// <summary>