mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -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;
|
||||
}
|
||||
if (this.serverConnection != null)
|
||||
{
|
||||
if (disposing && this.ownConnection)
|
||||
{
|
||||
this.serverConnection.Disconnect();
|
||||
}
|
||||
this.serverConnection = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
|
||||
/// </summary>
|
||||
public string ObjectUrn { get; set; }
|
||||
/// <summary>
|
||||
/// The target database name.
|
||||
/// </summary>
|
||||
public string Database { get; set; }
|
||||
/// <summary>
|
||||
/// URI of the underlying connection for this request
|
||||
/// </summary>
|
||||
public string ConnectionUri { get; set; }
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
|
||||
/// </summary>
|
||||
public string ObjectUrn { get; set; }
|
||||
/// <summary>
|
||||
/// The target database name.
|
||||
/// </summary>
|
||||
public string Database { get; set; }
|
||||
/// <summary>
|
||||
/// URI of the underlying connection for this request
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
ServerPrototype prototype = new ServerPrototype(dataContainer);
|
||||
|
||||
if (prototype != null)
|
||||
this.serverViewInfo.ObjectInfo = new ServerInfo()
|
||||
{
|
||||
this.serverViewInfo.ObjectInfo = new ServerInfo()
|
||||
{
|
||||
Name = prototype.Name,
|
||||
HardwareGeneration = prototype.HardwareGeneration,
|
||||
Language = prototype.Language,
|
||||
MemoryInMB = prototype.MemoryInMB,
|
||||
OperatingSystem = prototype.OperatingSystem,
|
||||
Platform = prototype.Platform,
|
||||
Processors = prototype.Processors,
|
||||
IsClustered = prototype.IsClustered,
|
||||
IsHadrEnabled = prototype.IsHadrEnabled,
|
||||
IsPolyBaseInstalled = prototype.IsPolyBaseInstalled,
|
||||
IsXTPSupported = prototype.IsXTPSupported,
|
||||
Product = prototype.Product,
|
||||
ReservedStorageSizeMB = prototype.ReservedStorageSizeMB,
|
||||
RootDirectory = prototype.RootDirectory,
|
||||
ServerCollation = prototype.ServerCollation,
|
||||
ServiceTier = prototype.ServiceTier,
|
||||
StorageSpaceUsageInMB = prototype.StorageSpaceUsageInMB,
|
||||
Version = prototype.Version,
|
||||
MinServerMemory = prototype.MinServerMemory,
|
||||
MaxServerMemory = prototype.MaxServerMemory,
|
||||
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
||||
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
||||
NumaNodes = prototype.NumaNodes
|
||||
};
|
||||
}
|
||||
return Task.FromResult(new InitializeViewResult { ViewInfo = this.serverViewInfo, Context = context });
|
||||
Name = prototype.Name,
|
||||
HardwareGeneration = prototype.HardwareGeneration,
|
||||
Language = prototype.Language,
|
||||
MemoryInMB = prototype.MemoryInMB,
|
||||
OperatingSystem = prototype.OperatingSystem,
|
||||
Platform = prototype.Platform,
|
||||
Processors = prototype.Processors,
|
||||
IsClustered = prototype.IsClustered,
|
||||
IsHadrEnabled = prototype.IsHadrEnabled,
|
||||
IsPolyBaseInstalled = prototype.IsPolyBaseInstalled,
|
||||
IsXTPSupported = prototype.IsXTPSupported,
|
||||
Product = prototype.Product,
|
||||
ReservedStorageSizeMB = prototype.ReservedStorageSizeMB,
|
||||
RootDirectory = prototype.RootDirectory,
|
||||
ServerCollation = prototype.ServerCollation,
|
||||
ServiceTier = prototype.ServiceTier,
|
||||
StorageSpaceUsageInMB = prototype.StorageSpaceUsageInMB,
|
||||
Version = prototype.Version,
|
||||
MinServerMemory = prototype.MinServerMemory,
|
||||
MaxServerMemory = prototype.MaxServerMemory,
|
||||
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
||||
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
||||
NumaNodes = prototype.NumaNodes
|
||||
};
|
||||
}
|
||||
var context = new ServerViewContext(requestParams);
|
||||
return Task.FromResult(new InitializeViewResult { ViewInfo = this.serverViewInfo, Context = context });
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
ConnectionInfo connInfo = this.GetConnectionInfo(viewParams.ConnectionUri);
|
||||
|
||||
|
||||
using (var dataContainer = CDataContainer.CreateDataContainer(connInfo))
|
||||
{
|
||||
try
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
// 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
|
||||
{
|
||||
public class ServerViewContext : SqlObjectViewContext
|
||||
{
|
||||
public ServerConnection Connection { get; }
|
||||
public ServerViewContext(Contracts.InitializeViewRequestParams parameters, ServerConnection connection) : base(parameters)
|
||||
public ServerViewContext(Contracts.InitializeViewRequestParams parameters) : base(parameters)
|
||||
{
|
||||
this.Connection = connection;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user