NEWSEQUENTIALID () not working in SQL Server for Linux?
I am running MS SQL Server for Linux from a Docker image ( https://hub.docker.com/r/microsoft/mssql-server-linux/ )
I found in my log files that there are many PRIMARY KEY violations that have a column in my log table ID uniqueidentifier DEFAULT NEWSEQUENTIALID()
.
An exception:
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 the documentation
NEWSEQUENTIALID is a wrapper over the Windows function UuidCreateSequential.
(source: https://docs.microsoft.com/en-us/sql/t-sql/functions/newsequentialid-transact-sql )
How does it work on linux? Is the behavior broken as the generated GUIDs must be unique and they clearly are not.
Reproduction stages
-
Run mccql-server-linux docker image
docker run mssql-server-linux
(see https://hub.docker.com/r/microsoft/mssql-server-linux/ for details ) -
Create table
CREATE TABLE SequentialIdTest(ID uniqueidentifier PRIMARY KEY DEFAULT NEWSEQUENTIALID(), ColA int );
-
Insert new line
INSERT INTO SequentialIdTest(ColA) VALUES (0);
-
reload docker image
docker restart {CONTAINER_NAME}
-
Try to insert a new line again
INSERT INTO SequentialIdTest(ColA) VALUES (0);
source to share
No one has answered this question yet
See similar questions:
or similar: