mssql-docker icon indicating copy to clipboard operation
mssql-docker copied to clipboard

An unexpected error occurred while checking the sector size for file

Open schrc3b6 opened this issue 6 years ago • 5 comments

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.

schrc3b6 avatar Jun 16 '20 11:06 schrc3b6

Hello there,

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

Cheers,

croblesm avatar Jun 24 '20 20:06 croblesm

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.

maleu1 avatar Jun 26 '20 08:06 maleu1

Hi

@dbamaster thanks for the link.

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

schrc3b6 avatar Jun 29 '20 13:06 schrc3b6

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();
            });
        }

art-grig avatar Jun 30 '20 21:06 art-grig

Also seeing this issue, intermittently (super annoying).

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

badeball avatar Nov 27 '20 11:11 badeball