Mssql-docker: An unexpected error occurred while checking the sector size for file

Created on 16 Jun 2020  路  5Comments  路  Source: microsoft/mssql-docker

Hi,

We are getting the following error message when creating multiple databases in parallel tests.

System.AggregateException : One or more errors occurred. (An unexpected error occurred while checking the sector size for file '/var/opt/mssql/data/Test_cb35ee46b3d44d8a9c53470a1b7b7be9_log.ldf'. Move the file to a local NTFS volume, where the sector size can be retrieved. Check the SQL Server error log for more information. 

CREATE DATABASE failed. Some file names listed could not be created. Check related errors.) (The following constructor parameters did not have matching fixture data: TestServerFixture testServerFixture) 

---- Microsoft.Data.SqlClient.SqlException : An unexpected error occurred while checking the sector size for file '/var/opt/mssql/data/Test_cb35ee46b3d44d8a9c53470a1b7b7be9_log.ldf'. Move the file to a local NTFS volume, where the sector size can be retrieved. Check the SQL Server error log for more information. 

CREATE DATABASE failed. Some file names listed could not be created. Check related errors. 

We are starting the container via the following command:

docker run --name 'mssql-2019' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=***********' -p 1433:1433 --net SqlServerNetwork --net-alias mssql -d mcr.microsoft.com/mssql/server:2019-latest

Docker version 18.09.6, build 481bc77
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64

The parallel execution is realized using collections as defined here: https://xunit.net/docs/running-tests-in-parallel.html

var dataSeedManager = new DataSeedManager<DbContext>(CreateDbContext(), databaseExisted); 

using (DbContext dbContext = CreateDbContext()) 
{ 
dbContext.Database.Migrate(); 
} 

using (IdentityDbContext context = CreateIdentityContext()) 
{ 

context.Database.Migrate(); 
} 


dataSeedManager.RegisterSeedsFromDbContextAssembly(); 
dataSeedManager.SeedData(); 

dbContext.Database.ExecuteSqlRaw( 
"BACKUP DATABASE [IntegrationTest] TO DISK = 'integration_database.bak' WITH INIT, SKIP"); 

Any help would be very much appreciated.

Most helpful comment

Got exactly the same issue in the same scenario, as a workaround for now configured retry policy for db creation while running tests, here is the code:

private static readonly IAsyncPolicy CreatePolicy = Policy
            .Handle<SqlException>(e => e.Number == 5177)
            .WaitAndRetryAsync(new[]
            {
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                TimeSpan.FromSeconds(3),
            });

public async Task InitializeAsync()
        {
            await CreatePolicy.ExecuteAsync(async () => {
                await _dbContext.Database.EnsureDeletedAsync();
                await _dbContext.Database.EnsureCreatedAsync();
            });
        }

All 5 comments

Hello there,

According SQL Server on Linux documentation, only XFS and EXT4 are supported.
You might want to take a look here.

Cheers,

Thank you for your response. We will definitely look into this.
Just one little thing to add to our issue: The test suite works perfectly fine when we run the tests sequentially. The issue occurs randomly when running the tests in parallel.

Hi

@dbamaster thanks for the link.

However we are running docker on ext4 und using overlay2 as storage driver as the prerequisites lists.

Got exactly the same issue in the same scenario, as a workaround for now configured retry policy for db creation while running tests, here is the code:

private static readonly IAsyncPolicy CreatePolicy = Policy
            .Handle<SqlException>(e => e.Number == 5177)
            .WaitAndRetryAsync(new[]
            {
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                TimeSpan.FromSeconds(3),
            });

public async Task InitializeAsync()
        {
            await CreatePolicy.ExecuteAsync(async () => {
                await _dbContext.Database.EnsureDeletedAsync();
                await _dbContext.Database.EnsureCreatedAsync();
            });
        }

Also seeing this issue, intermittently (super annoying).

Edit: Using the mssql/server:2017-CU14-ubuntu image.

Was this page helpful?
0 / 5 - 0 ratings