Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$SqlConnection.Close() not in a finally block #124

Closed
rancourt-martin opened this issue Oct 31, 2023 · 3 comments · Fixed by #142
Closed

$SqlConnection.Close() not in a finally block #124

rancourt-martin opened this issue Oct 31, 2023 · 3 comments · Fixed by #142
Assignees
Labels
bug Something isn't working

Comments

@rancourt-martin
Copy link

Hi,
(amazing piece of code that saved me weeks of back and forth with a client)
fyi, I ran into the case where after completion of psblitz, connection is not closed and lingers on the sqlserver. we suspect this is caused by the $SqlConnection.Close() (or dispose) not being in a "finally" block.

@VladDBA VladDBA self-assigned this Oct 31, 2023
@VladDBA VladDBA added the bug Something isn't working label Oct 31, 2023
@VladDBA
Copy link
Owner

VladDBA commented Oct 31, 2023

Hi @rancourt-martin ,
Thank you for the feedback!
I'm glad you find it useful.
I'll address this bug in the next release.

@VladDBA
Copy link
Owner

VladDBA commented Nov 10, 2023

Hi Martin,
I've added another pair of $SqlConnection.Close() and $SqlConnection.Dispose() (there already is a $SqlConnection.Dispose() at the begging of the finally block), but the connection still remains after PSBlitz execution finishes.
The good news is that closing the PowerShell window from which PSBlitz was executed causes the leftover connection to close immediately. If the PS window is left open the leftover connection disappears from SQL Server within 3 minutes, at least from what I've tested.

@VladDBA VladDBA closed this as completed Nov 10, 2023
@VladDBA VladDBA reopened this Nov 10, 2023
@rancourt-martin
Copy link
Author

rancourt-martin commented Nov 11, 2023 via email

@VladDBA VladDBA mentioned this issue Nov 14, 2023
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants