Modifying files in Managed Instance might fail with the error 3023

Jovan Popovic
Azure SQLDB Managed Instance
2 min readOct 15, 2018

If you are using Azure SQL Database Managed Instance and if you want to add or remove some file on a database, you might occasionally get the following error message:

Msg 3023, Level 16, State 2, Line 1
Backup and file manipulation operations (such as ALTER DATABASE ADD FILE) on a database must be serialized. Reissue the statement after the current backup or file manipulation operation is completed.

This is a transient error that happens because you executed ALTER DATABASE ADD FILE command while there is some ongoing backup command (for example, backup log that happens every 5min but it is very fast, or differential/full database backup that might be longer operation). The command will succeed if you try it again later.

If you want to check is there some ongoing backup command that is running, you can run the following query:

SELECT
query = a.text, start_time, percent_complete,
eta = dateadd(second,estimated_completion_time/1000, getdate()),
command
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command LIKE '%BACKUP%'

If you get some result, it means that you will not be able to modify files until the command finishes. On the following picture you can see that the query gives you ETA when the backup will complete:

If you see the result of this query, you will need to wait until ETA to run your command.

--

--

Jovan Popovic
Azure SQLDB Managed Instance

Program manager working in Microsoft on Azure SQL Managed Instance and various SQL Server features such as T-SQL language, JSON, Hekaton, Column store, Temporal