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

SqlAGReplica: InnerException: Invalid column name 'required_copies_to_commit' #1033

Closed
shurick81 opened this issue Jan 25, 2018 · 12 comments · Fixed by #1576
Closed

SqlAGReplica: InnerException: Invalid column name 'required_copies_to_commit' #1033

shurick81 opened this issue Jan 25, 2018 · 12 comments · Fixed by #1576
Labels
documentation The issue is related to documentation only.

Comments

@shurick81
Copy link
Contributor

Details of the scenario you tried and the problem that is occurring:
I am trying to configure availability group.
I get following error when applying DSC:

VERBOSE: [FKV04SPDB]: LCM:  [ End    Set      ]  [[SqlAGReplica]AddReplica]  in 3.5350 seconds.
PowerShell DSC resource MSFT_SqlAGReplica  failed to execute Set-TargetResource functionality with error message:
Creating the Availability Group Replica 'AG01' failed on the instance 'SPIntra01'. InnerException: Invalid column name
'required_copies_to_commit'.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : fkv04spdb
VERBOSE: [FKV04SPDB]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : fkv04spdb

The DSC configuration that is using the resource (as detailed as possible):

        SqlServerLogin AddNTServiceClusSvc
        {
            Ensure               = 'Present'
            Name                 = $SQLServiceAccountCredential.UserName
            LoginType            = 'WindowsUser'
            ServerName           = $nodeName
            InstanceName         = $SQLInstanceName
            PsDscRunAsCredential = $SPInstallAccountCredential
        }

        SqlServerPermission AddNTServiceClusSvcPermissions
        {
            Ensure               = 'Present'
            ServerName           = $nodeName
            InstanceName         = $SQLInstanceName
            Principal            = $SQLServiceAccountCredential.UserName
            Permission           = 'AlterAnyAvailabilityGroup', 'ViewServerState'
            PsDscRunAsCredential = $SPInstallAccountCredential
            DependsOn            = '[SqlServerLogin]AddNTServiceClusSvc'
        }

        SqlAlwaysOnService 'EnableAlwaysOn'
        {
            Ensure               = 'Present'
            ServerName           = $nodeName
            InstanceName         = $SQLInstanceName
            RestartTimeout       = 120
            PsDscRunAsCredential = $SPInstallAccountCredential
        }
        
        SqlServerEndpoint HADREndpoint
        {
            EndPointName         = 'HADR'
            Ensure               = 'Present'
            Port                 = 5022
            ServerName           = $nodeName
            InstanceName         = $SQLInstanceName
            PsDscRunAsCredential = $SPInstallAccountCredential
        }

        SqlServerEndpointPermission SQLConfigureEndpointPermission
        {
            Ensure               = 'Present'
            ServerName           = $nodeName
            InstanceName         = $SQLInstanceName
            Name                 = 'HADR'
            Principal            = $SQLServiceAccountCredential.UserName
            Permission           = 'CONNECT'
            PsDscRunAsCredential = $SPInstallAccountCredential
            DependsOn            = '[SqlServerEndpoint]HADREndpoint'
        }

        $clusterDependency = '[WindowsFeature]RSATClusteringCmdInterface';

        if ( $NodeName -eq $SQLWSFCFirstNode )
        {
            
            SqlAG PrimaryAG
            {
                Ensure                  = 'Present'
                Name                    = $SQLAGName
                ServerName              = $nodeName
                InstanceName            = $SQLInstanceName
                PsDscRunAsCredential    = $SPInstallAccountCredential
                DependsOn               = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions'
            }

            SqlAGListener AvailabilityGroupListener
            {
                Ensure                  = 'Present'
                ServerName              = $nodeName
                InstanceName            = $SQLInstanceName
                AvailabilityGroup       = $SQLAGName
                Name                    = $mainParameters.SQLListenerName
                IpAddress               = $mainParameters.SQLListenerIPAddress
                Port                    = 1433
                PsDscRunAsCredential    = $SPInstallAccountCredential
                DependsOn               = '[SqlAG]PrimaryAG'
            }

        } else {

            SqlAGReplica AddReplica
            {
                Ensure                      = 'Present'
                Name                        = $SQLAGName
                AvailabilityGroupName       = $SQLAGName
                ServerName                  = $nodeName
                InstanceName                = $SQLInstanceName
                PrimaryReplicaServerName    = $SQLWSFCFirstNode
                PrimaryReplicaInstanceName  = $SQLInstanceName
                ProcessOnlyOnActiveNode     = $true
                PsDscRunAsCredential        = $SPInstallAccountCredential
            }

        }

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Windows Server 2016
WMF 5.1
What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
I use SqlServerDsc 10.0.0.0 module. Don't know about SqlServer or SQLPS.

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
I just install from gallery via DSC:

                    PSModule "PSModule_$_"
                    {
                        Ensure              = "present" 
                        Name                = "SqlServerDsc"
                        Repository          = "PSGallery"
                        InstallationPolicy  = "trusted"
                        RequiredVersion     = "10.0.0.0"    
                    }
@shurick81
Copy link
Contributor Author

I found this similar issue:
https://social.msdn.microsoft.com/Forums/azure/en-US/3e5db95a-0231-4e29-b0c0-68c4d8e9583d/exception-occurred-microsoftsqlservermanagementcommonexecutionfailureexception?forum=sqltools

Is there a way to guarantee what module version to use?

One more thing to mention is that we use SQL Server 2017 Enterprise.

@johlju
Copy link
Member

johlju commented Jan 25, 2018

So this is a problem with SQLPS module, maybe we should document that 🤔 It seems that it was solved using SqlServer module.

SQLPS is part of SQL Server, but SQL Server Team are moving away (I think) from SQLPS in favor of SqlServer module (which is not the same as SqlServerDsc). SqlServer module is published in the PowerShell Gallery. It can be downloaded from there; https://www.powershellgallery.com/packages/SqlServer/
If SqlServer module is present on the target node, then that will be used instead of the "older" SQLPS module.

@johlju
Copy link
Member

johlju commented Jan 25, 2018

@randomnote1 Are you familiar with this issue? Is this a know problem with the SQLPS module? Should we add a requirement for this resource (in the README.md) that SqlServer module must be used?

@johlju johlju added the question The issue is a question. label Jan 25, 2018
@randomnote1
Copy link
Contributor

I think I recall hearing something about this before, but I'm not sure. I've been relying on the SQLPS module (SQL 2014 & 2016) and haven't experienced this yet.

I don't know how well could enforce the requirement to use the SqlServer module because all the resources rely on the Import-SqlPsModule helper function. I would imagine this would end up being a module-wide decision with the SqlServer module being referenced in the manifest as a dependent module. That's a pretty big breaking change, but since the SqlServer module is the way of the future, it's probably worth considering.

@shurick81
Copy link
Contributor Author

shurick81 commented Jan 25, 2018

Thank you very much for considering this.

Any dirty workaround for me? :)
My alternative now is running SQL queries from DSC via Script resource.

@randomnote1
Copy link
Contributor

@shurick81, I would try installing the SqlServer module from the PSGallery. The helper function looks for this module to be present first, and prefers it over SQLPS.

@shurick81
Copy link
Contributor Author

Thanks, I run Install-Module SqlServer -RequiredVersion 21.0.17199 -Force -AllowClobber on each SQL machine and now I get another error:

PowerShell DSC resource MSFT_SqlAGReplica  failed to execute Set-TargetResource functionality with error message:
Failed to join the availability group replica 'AG01'. InnerException: An error occurred while attempting to access
availability replica 'FKV04SPDB\SPINTRA01' in availability group 'AG01'.  The availability replica is not found in the
availability group configuration.  Verify that the availability group and availability replica names are correct, then
retry the command.
Failed to join local availability replica to availability group 'AG01'.  The operation encountered SQL Server error
41167 and has been rolled back.  Check the SQL Server error log for more details.  When the cause of the error has
been resolved, retry the ALTER AVAILABILITY GROUP JOIN command.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : fkv04spdb

VERBOSE: [FKV04SPDB]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : fkv04spdb

However, it can be completely another issue to look at.

@randomnote1
Copy link
Contributor

Cool! Got past one issue :)

Yes, it looks like you're on to a different issue. Verify the FKV04SPDB\SPINTRA01 instance is added to the availability group as a replica. The name must match what is listed in SSMS in my experience.

@vors vors removed the question The issue is a question. label Jan 25, 2018
@johlju
Copy link
Member

johlju commented Jan 25, 2018

@randomnote1 I didn't mean enforce the use of it, I thought we could just mention in the README.md for SqlAGreplica (under requirements section) that SqlServer is needed in some scenarios for SQL Server 2017.
On the other hand, this is probably a bug, I would believe this should be supported with the built-in SQLPS as long that is shipped with SQL Server.
So maybe hold of on this if this is getting fixed. People searching for this error will hit this issue once it has been indexed.

@johlju johlju changed the title InnerException: Invalid column name 'required_copies_to_commit' in SqlAGReplica SqlAGReplica: InnerException: Invalid column name 'required_copies_to_commit' Jan 25, 2018
@emyatsuna
Copy link

Hi, I am also getting the same error. The manual workaround running the Install-Module SqlServer -RequiredVersion 21.0.17199 -Force using PS solves my problem. Is there an update with this one? Thanks.

@johlju
Copy link
Member

johlju commented Nov 12, 2019

One suggestion was to add SqlServer module as a requirement (in the documentation) so no other workaround.

Anyone know if there still is a SQLPS in SQL2019?

@johlju johlju reopened this Nov 12, 2019
@johlju
Copy link
Member

johlju commented Nov 12, 2019

Reopen to add this to the documentation.

@johlju johlju added documentation The issue is related to documentation only. help wanted The issue is up for grabs for anyone in the community. labels Nov 12, 2019
johlju added a commit to johlju/SqlServerDsc that referenced this issue Jun 26, 2020
@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Jun 26, 2020
johlju added a commit to johlju/SqlServerDsc that referenced this issue Jun 26, 2020
johlju added a commit that referenced this issue Jul 1, 2020
- SqlServerDsc
  - Remove the file `.github/CONTRIBUTION.md` as it no longer filled any
    purpose as GitHub will find the CONTRIBUTION.md in the root folder
    directly now (issue #1227).
  - The documentation in CONTRIBUTING.md has been somewhat updated.
  - Update documentation around design pattern for accounts that does not
    use passwords (issue #378)
    and (issue #1230).
  - Updating the Integration Test README.md to better explain what the
    integration tests for SqlSetup, SqlRSSetup, and SqlRS does (issue #1315).
- SqlAGReplica
  - Update documentation with a requirement for SqlServer in certain circumstances
    (issue #1033).
- SqlRSSetup
  - There was a typo in the error message that was thrown when not passing
    either the `Edition` or `ProductKey` that could be misleading (issue #1386).
  - Updated the parameter descriptions for the parameters `Edition` and
    `ProductKey` that they are mutually exclusive (issue #1386).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue is related to documentation only.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants