NEWSEQUENTIALID() is broken in SQL Server for linux?

486 views Asked by At

I am running MS SQL Server for linux from a Docker image (https://hub.docker.com/r/microsoft/mssql-server-linux/)

I've discovered in my log files, that there are many PRIMARY KEY violations on my log table, which has ID uniqueidentifier DEFAULT NEWSEQUENTIALID() column.

Exception is:

Exception: System.Data.SqlClient.SqlException: 
Violation of PRIMARY KEY constraint 'PK_Logs'. 
Cannot insert duplicate key in object 'dbo.Logs'. 
The duplicate key value is (20c0423e-f36b-1410-8020-800000000000).

As stated in documentation

NEWSEQUENTIALID is a wrapper over the Windows UuidCreateSequential function.

(source: https://learn.microsoft.com/en-us/sql/t-sql/functions/newsequentialid-transact-sql)

How does it work on linux then? Is the behaviour broken, since generated GUIDs should be unique, and they are clearly not.

Reproduction steps

  1. start mssql-server-linux docker image docker run mssql-server-linux (refer to https://hub.docker.com/r/microsoft/mssql-server-linux/ for details)

  2. Create table CREATE TABLE SequentialIdTest(ID uniqueidentifier PRIMARY KEY DEFAULT NEWSEQUENTIALID(), ColA int );

  3. Insert new row INSERT INTO SequentialIdTest(ColA) VALUES (0);

  4. restart docker image docker restart {CONTAINER_NAME}

  5. Try to insert new row again INSERT INTO SequentialIdTest(ColA) VALUES (0);

0

There are 0 answers