microsoft / microsoft/DacFx

unclear error messages when sqlpackage fails deploying to containers with less than minimum memory

Open
#837 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

- SqlPackage or DacFx Version: 170.4.83.3
- .NET Framework (Windows-only) or .NET Core: netfx
- Environment (local platform and source/target platforms): Client on Windows 11 arm64, Server is x64 sqlserver container `mcr.microsoft.com/mssql/server:2022-latest`

**Steps to Reproduce:**

1. Deploy server container with low memory limit (e.g. 512MB)
2. Run sqlpackage to deploy a project, deploy succeeds
2. Run sqlpackage to deploy again (should be no-op), deploy fails with `CREATE SCHEMA` already exists. Reviewing the script, it is acting as if the deploy has never occurred.

Checking in SQL Server Profiler shows that it is running a [very large batch](https://github.com/user-attachments/files/31479987/huge_batch.sql) and that the batch is failing with the error:

> Msg 802, Level 16, State 1, Line 402
> There is insufficient memory available in the buffer pool.

This error does not show up in VS UI or command line output, though.

```text
C:\Users\foo>sqlpackage /a:publish /sf:example.dacpac /tsn:container.host.name /tdn:example /tu:sa /tp:blah /ttsc:true
Publishing to database 'example' on server 'container.host.name'.
Initializing deployment (Start)
Initializing deployment (Complete)
Analyzing deployment plan (Start)
Analyzing deployment plan (Complete)
Updating database (Start)
Creating User-Defined Data Type [dbo].[StreetAddress]...
An error occurred while the batch was being executed.
Updating database (Failed)
*** Could not deploy package.
Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 219, Level 16, State 1, Line 1 The type 'dbo.StreetAddress' already exists, or you do not have permission to create it.
Error SQL72045: Script execution error. The executed script:
CREATE TYPE [dbo].[StreetAddress]
FROM NVARCHAR (256) NULL;

Time elapsed 0:00:57.65

C:\Users\foo>
```

**Expected behavior**

The deploy either fails with a clear error message or succeeds.

**Did this occur in prior versions? If not - which version(s) did it work in?**

Probably? Haven't checked prior revisions.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the listed sqlpackage publish command against the low-memory SQL Server container and compare the profiler's Msg 802 with the command-line output. Trace how the failed batch and deployment errors are surfaced, using the provided huge_batch.sql as the failing input. Done means the memory failure is reported clearly instead of the misleading CREATE TYPE or CREATE SCHEMA error.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
cli, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.