-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Connect-DbaInstance - Open connection to get CurrentDatabase #9308
Conversation
No idea why the datamasking tests fail. Do you need more details on this pull request? |
I don't have an instance at work to test this but curious what affect (with your fix) does it have using a DedicatedAdminConnection ? And then can we ensure at most doing a connection to Azure SQL still functions correctly? (just to double-check) |
Should not have any effect on DAC as DAC is always NonPooled. Will test Azure SQL now... |
Works on Azure as well. Here I have some screenshots. Because of the empty Now the connection is opened during the second run of Also did some query tests - everything works fine. |
I can reproduce the failing test on my local lab. Will analyse the issue and add additional commits to this branch. |
So this is really strange. dbatools/public/Invoke-DbaDbDataMasking.ps1 Line 339 in 95c9644
This refresh just clears the SMO at this point, so If we force a NonPooled connection, the SMO is not cleared. So this issue might be related to the way SMO handles the connection pooling. As the data masking commands are not a central part of the module, I would like to leave it like this and use a non pooled connection to solve the issue. |
Here is code that shows the problem:
Here is code that works as expected:
So the problem is somewhere inside of I will try to find some time in the next days to get the root cause. |
While analyzing, I discovered a bug that was introduced with #8764 into
In this case, This works:
I have seen another issue in |
Sorry about the back and forth on this pull requst. My initial aproch was not good and had some side effects. Now I optimized the code to only do the necessary steps. So only if the database context needs to be checked and only if the connection is closed and thus the CurrentDatabase is empty, we open the connection to get the value. This solves the initial issue, test on DataMasking pass now without changing the code there and it works on Azure SQL Database as well without problems. |
I very much appreciate the time you took to investigate this, thank you. that was so interesting, and only one command across a whole suite! amazing. the fix looks perfect in scope 🙏🏼 |
Type of Change
.\tests\manual.pester.ps1
)Purpose
To be able to reliably evaluate property CurrentDatabase, the connection must first be opened.
See #9307 for more details.