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

[Bug] Set-DbaDbRecoveryModel - error on snapshot #5534

Closed
2 of 3 tasks
olegstrutinskii opened this issue May 16, 2019 · 1 comment
Closed
2 of 3 tasks

[Bug] Set-DbaDbRecoveryModel - error on snapshot #5534

olegstrutinskii opened this issue May 16, 2019 · 1 comment

Comments

@olegstrutinskii
Copy link
Contributor

Before submitting a bug report:

### PowerShell version:
Name                           Value
----                           -----
PSVersion                      5.1.17763.316
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.316
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

### dbatools Module version:
Name    : dbatools
Path    : E:\github\sqlcollaborative\dbatools.psm1
Version : 0.9.828
  • Running latest release of dbatools
  • Verified errors are not related to permissions
  • Is this bug with Copy-DbaDatabase? You can replicate it using Backup-DbaDatabase ... | Restore-DbaDatabase ...

NOTE: Copy-DbaDatabase will not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.

SQL Server:

Microsoft SQL Server 2017 (RTM-CU13-OD) (KB4483666) - 14.0.3049.1 (X64)   Dec 15 2018 11:16:42   Copyright (C) 2017 Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor) 

Errors Received

PSMessageDetails      :
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "Alt
                        er" with "0" argument(s): "Alter failed for Database 'test_dv_ss1'. " ---> Mic
                        rosoft.SqlServer.Management.Smo.FailedOperationException: Alter failed for Dat
                        abase 'test_dv_ss1'.  ---> Microsoft.SqlServer.Management.Common.ExecutionFail
                        ureException: An exception occurred while executing a Transact-SQL statement o
                        r batch. ---> System.Data.SqlClient.SqlException: The operation cannot be perf
                        ormed on a database snapshot.
                        ALTER DATABASE statement failed.
                           at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(Exec
                        uteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchExc
                        eption)
                           at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(S
                        tring sqlCommand, ExecutionTypes executionType, Boolean retry)
                           --- End of inner exception stack trace ---
                           at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(S
                        tring sqlCommand, ExecutionTypes executionType, Boolean retry)
                           at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(S
                        tringCollection sqlCommands, ExecutionTypes executionType, Boolean retry)
                           at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCo
                        llection queries, Boolean includeDbContext, Boolean executeForAlter)
                           at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AlterImplFinish(StringCo
                        llection alterQuery, ScriptingPreferences sp)
                           at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AlterImplWorker()
                           at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AlterImpl()
                           --- End of inner exception stack trace ---
                           at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AlterImpl()
                           at CallSite.Target(Closure , CallSite , Object )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocat
                        ionException(Exception exception, Type typeToThrow, String methodName, Int32 n
                        umArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Object )
                           at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site,
                         T0 arg0)
                           at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(Interp
                        retedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction
                        .Run(InterpretedFrame frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : FailedOperationException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Set-DbaDbRecoveryModel<Process>, <No file>: line 141
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

Steps to Reproduce

have a database snapshot on server
Set-DbaDbRecoveryModel -SqlInstance <SERVER> -RecoveryModel Simple -AllDatabases

Expected Behavior

Skip recovery model change for snapshots

Actual Behavior

Exception calling "Alter" with "0" argument(s): "Alter failed for Database 'test_dv_ss1'. "
At line:141 char:21
+                     $db.Alter()
+                     ~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FailedOperationException
mikepetrak added a commit to mikepetrak/dbatools that referenced this issue May 20, 2019
Ignore database snapshots to address dataplat#5534.
potatoqualitee pushed a commit that referenced this issue May 20, 2019
* Remove hard coded database name

* Update Set-DbaDbRecoveryModel.ps1

Ignore database snapshots to address #5534.

* Removed extra line.
@potatoqualitee
Copy link
Member

fixed in prerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants