-
Notifications
You must be signed in to change notification settings - Fork 225
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
SqlTraceFlag: Unable to alter trace flags #1834
Comments
This looks like a bug. We should add an integration tests to test this. Can you please check what the actual startup parameters (what the string look like) are on the Database Engine service so it is possible to reproduce the exact error? |
Thanks for your quick response. As mentioned above, the script works fine if there are no existing trace flags present, but as soon as there are any, the script fails with the error I have given. And it makes no difference if the trace flag given in the script is already existing in the instance or completely new one. The startup parameters currently in my lab system are:
Hope this helps? |
That helps, it was the property Could you try making the values string (and force it to array) to see if that works, or generates another error message? SqlTraceFlag 'SetTraceFlags'
{
ServerName = $Node.NodeName
InstanceName = $SqlInstanceName
TraceFlags = @('3226', '4199')
RestartService = $true
} |
Also, curious what you ran to get the output in your last comment - I'm seeing the property |
I was using dbatools, Get-StartupParameter cmdlet. Will try your suggestion shortly and reporting back. |
Tried your suggestion, but the exception is unfortunately the same. Just thinking, but as there is currently just one value '4199' the exception seems to indicate reading the current value is the problem? To make it maybe more readable for you, I have now changed the existing trace flag to 2371 and with the code below I am trying to replace 2371 with 3226 and 4199.
Startup Parameters are now:
|
Thanks for the information! Looked at their code, and they parse it the same way the resource does.
You are correct. I wonder if it is SqlServerDsc/source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1 Lines 382 to 392 in bed3b12
I would test to change this code to the following: if ($null -ne $getTargetResourceResult.TraceFlags)
{
$reference.AddRange(@($getTargetResourceResult.TraceFlags))
}
$difference = [System.Collections.ArrayList]::new()
if ($null -ne $TraceFlags)
{
$difference.AddRange(@($TraceFlags))
} If it is a single current value we force it to an array. I saw that there is no integration tests at all, that is probably why this bug slipped through. We should add an integration tests, I added an issue (#1835) to track that. |
Thanks a lot for your help, Johan. I will try the code you posted and report back. :) |
Most likey the above is the error, looking att the method
If you like, you can update the lines above in the file DSC_SqlTraceFlag.psm1 on the lab server, then run your configuration again. To verify that it works. I can throw together and integration test this weekend. I had totally missed that we didn't have one. |
Yes, sorry I had a short circuit in my understanding. :D The new code indeed seems to work without problems when using TraceFlags:
|
Awesome. If you like, you maybe send in a PR for that change, otherwise I will fix it when I add the integration test. 🙂 |
Thanks Johan. The TraceFlagsToInclude still seems to need some tuning as it throws the same exception as before. I can try something to address that if you have idea at hand? But that will happen tomorrow. ;) Othwerise I believe you are able to fix that as well as soon as you have the integration test. I am in no hurry with this fix so no worries, take your time. |
I didn't have time this weekend. I worked on another PR that took longer than expected. Try to get to this next weekend (or during the week if I have time). |
- SqlServerDsc - The AppVeyor configuration file was updated to include the possibility to run skip installing one or more SQL Server instances when debugging in AppVeyor to help maximize the time alloted be run. - SqlTraceFlag - The resource is now tested with an integration tests (issue #1835). - A new parameter `ClearAllTraceFlags` was added so a configuration can enforce that there should be no trace flags. - The examples was updated to show that values should be passed as an array, even when there is only one value. - `Get-TargetResource` was updated to always return an array for parameter `TraceFlags`, `TraceFlagsToInclude`, and `TraceFlagsToInclude`. _The last_ _two properties will always return an empty array._ - `Set-TargetResource` was updated to handle a single trace flag in the current state (issue #1834). - `Set-TargetResource` was updated to correctly include or exclude a single flag (issue #1834).
The latest preview should now have a working SqlTraceFlag resource - the integration tests does work. |
Problem description
Hi,
I am using SqlTraceFlags to set the trace flags in the instance during the installation of the SQL Server. This seems to work fine when there are no trace flags present in the instance.
The problem is that now I am trying to write the tool which could be used to replace (or alter) the existing set of trace flags with the once desired. I have tried using TraceFlags and TraceFlagsToInclude with the similar results.
Code below is part of the script which works fine if there are no trace flags present in the instance but fails if any trace flags are already present. To my understanding below sample should simply replace any existing flags with the set of flags in the configuration (T3226 and T4199).
Thanks a lot for your assistance.
Kindest Regards,
Vesa
Verbose logs
DSC configuration
Suggested solution
Would like to know if this is a bug or if I am doing something wrong here. Thanks.
SQL Server edition and version
SQL Server PowerShell modules
Operating system
PowerShell version
SqlServerDsc version
The text was updated successfully, but these errors were encountered: