mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Simplify connection cleanup and clear pools to prevent lingering connections (#2199)
This commit is contained in:
@@ -1115,6 +1115,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
|||||||
}
|
}
|
||||||
this.managedConnection = null;
|
this.managedConnection = null;
|
||||||
}
|
}
|
||||||
|
if (this.serverConnection != null)
|
||||||
|
{
|
||||||
|
if (disposing && this.ownConnection)
|
||||||
|
{
|
||||||
|
this.serverConnection.Disconnect();
|
||||||
|
}
|
||||||
|
this.serverConnection = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ObjectUrn { get; set; }
|
public string ObjectUrn { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The target database name.
|
||||||
|
/// </summary>
|
||||||
|
public string Database { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// URI of the underlying connection for this request
|
/// URI of the underlying connection for this request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ConnectionUri { get; set; }
|
public string ConnectionUri { get; set; }
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ObjectUrn { get; set; }
|
public string ObjectUrn { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The target database name.
|
||||||
|
/// </summary>
|
||||||
|
public string Database { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// URI of the underlying connection for this request
|
/// URI of the underlying connection for this request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ConnectionUri { get; set; }
|
public string ConnectionUri { get; set; }
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,44 +32,41 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
public override Task<InitializeViewResult> InitializeObjectView(InitializeViewRequestParams requestParams)
|
public override Task<InitializeViewResult> InitializeObjectView(InitializeViewRequestParams requestParams)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo = this.GetConnectionInfo(requestParams.ConnectionUri);
|
ConnectionInfo connInfo = this.GetConnectionInfo(requestParams.ConnectionUri);
|
||||||
|
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
||||||
|
|
||||||
using (var context = new ServerViewContext(requestParams, ConnectionService.OpenServerConnection(connInfo, ObjectManagementService.ApplicationName)))
|
ServerPrototype prototype = new ServerPrototype(dataContainer);
|
||||||
|
|
||||||
|
if (prototype != null)
|
||||||
{
|
{
|
||||||
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
this.serverViewInfo.ObjectInfo = new ServerInfo()
|
||||||
|
|
||||||
ServerPrototype prototype = new ServerPrototype(dataContainer);
|
|
||||||
|
|
||||||
if (prototype != null)
|
|
||||||
{
|
{
|
||||||
this.serverViewInfo.ObjectInfo = new ServerInfo()
|
Name = prototype.Name,
|
||||||
{
|
HardwareGeneration = prototype.HardwareGeneration,
|
||||||
Name = prototype.Name,
|
Language = prototype.Language,
|
||||||
HardwareGeneration = prototype.HardwareGeneration,
|
MemoryInMB = prototype.MemoryInMB,
|
||||||
Language = prototype.Language,
|
OperatingSystem = prototype.OperatingSystem,
|
||||||
MemoryInMB = prototype.MemoryInMB,
|
Platform = prototype.Platform,
|
||||||
OperatingSystem = prototype.OperatingSystem,
|
Processors = prototype.Processors,
|
||||||
Platform = prototype.Platform,
|
IsClustered = prototype.IsClustered,
|
||||||
Processors = prototype.Processors,
|
IsHadrEnabled = prototype.IsHadrEnabled,
|
||||||
IsClustered = prototype.IsClustered,
|
IsPolyBaseInstalled = prototype.IsPolyBaseInstalled,
|
||||||
IsHadrEnabled = prototype.IsHadrEnabled,
|
IsXTPSupported = prototype.IsXTPSupported,
|
||||||
IsPolyBaseInstalled = prototype.IsPolyBaseInstalled,
|
Product = prototype.Product,
|
||||||
IsXTPSupported = prototype.IsXTPSupported,
|
ReservedStorageSizeMB = prototype.ReservedStorageSizeMB,
|
||||||
Product = prototype.Product,
|
RootDirectory = prototype.RootDirectory,
|
||||||
ReservedStorageSizeMB = prototype.ReservedStorageSizeMB,
|
ServerCollation = prototype.ServerCollation,
|
||||||
RootDirectory = prototype.RootDirectory,
|
ServiceTier = prototype.ServiceTier,
|
||||||
ServerCollation = prototype.ServerCollation,
|
StorageSpaceUsageInMB = prototype.StorageSpaceUsageInMB,
|
||||||
ServiceTier = prototype.ServiceTier,
|
Version = prototype.Version,
|
||||||
StorageSpaceUsageInMB = prototype.StorageSpaceUsageInMB,
|
MinServerMemory = prototype.MinServerMemory,
|
||||||
Version = prototype.Version,
|
MaxServerMemory = prototype.MaxServerMemory,
|
||||||
MinServerMemory = prototype.MinServerMemory,
|
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
||||||
MaxServerMemory = prototype.MaxServerMemory,
|
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
||||||
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
NumaNodes = prototype.NumaNodes
|
||||||
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
};
|
||||||
NumaNodes = prototype.NumaNodes
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return Task.FromResult(new InitializeViewResult { ViewInfo = this.serverViewInfo, Context = context });
|
|
||||||
}
|
}
|
||||||
|
var context = new ServerViewContext(requestParams);
|
||||||
|
return Task.FromResult(new InitializeViewResult { ViewInfo = this.serverViewInfo, Context = context });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task Save(ServerViewContext context, ServerInfo obj)
|
public override Task Save(ServerViewContext context, ServerInfo obj)
|
||||||
@@ -90,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
private string UpdateServerProperties(InitializeViewRequestParams viewParams, ServerInfo serverInfo, RunType runType)
|
private string UpdateServerProperties(InitializeViewRequestParams viewParams, ServerInfo serverInfo, RunType runType)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo = this.GetConnectionInfo(viewParams.ConnectionUri);
|
ConnectionInfo connInfo = this.GetConnectionInfo(viewParams.ConnectionUri);
|
||||||
|
|
||||||
using (var dataContainer = CDataContainer.CreateDataContainer(connInfo))
|
using (var dataContainer = CDataContainer.CreateDataContainer(connInfo))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -3,16 +3,12 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.SqlServer.Management.Common;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
||||||
{
|
{
|
||||||
public class ServerViewContext : SqlObjectViewContext
|
public class ServerViewContext : SqlObjectViewContext
|
||||||
{
|
{
|
||||||
public ServerConnection Connection { get; }
|
public ServerViewContext(Contracts.InitializeViewRequestParams parameters) : base(parameters)
|
||||||
public ServerViewContext(Contracts.InitializeViewRequestParams parameters, ServerConnection connection) : base(parameters)
|
|
||||||
{
|
{
|
||||||
this.Connection = connection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user