Hi guys.
There is a small issue in services configuration if we set UseStorageLock = true.
During tables initialization I'm having errors:
_Violation of PRIMARY KEY constraint 'PK_cap.Lock'. Cannot insert duplicate key in object 'cap.Lock'. The duplicate key value is (publish_retryv1)
_Violation of PRIMARY KEY constraint 'PK_cap.Lock'. Cannot insert duplicate key in object 'cap.Lock'. The duplicate key value is (received_retryv1)
As a solution I propose to add a check for Lock records existence here:
src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs
IF NOT EXISTS(SELECT 1 FROM {GetLockTableName()} WHERE [Key] = @PubKey)
INSERT INTO {GetLockTableName()} ([Key],[Instance],[LastLockTime]) VALUES(@PubKey,'',@LastLockTime);
IF NOT EXISTS(SELECT 1 FROM {GetLockTableName()} WHERE [Key] = @RecKey)
INSERT INTO {GetLockTableName()} ([Key],[Instance],[LastLockTime]) VALUES(@RecKey,'',@LastLockTime);
Hi guys. There is a small issue in services configuration if we set UseStorageLock = true. During tables initialization I'm having errors: _Violation of PRIMARY KEY constraint 'PK_cap.Lock'. Cannot insert duplicate key in object 'cap.Lock'. The duplicate key value is (publish_retryv1) _Violation of PRIMARY KEY constraint 'PK_cap.Lock'. Cannot insert duplicate key in object 'cap.Lock'. The duplicate key value is (received_retryv1)
As a solution I propose to add a check for Lock records existence here: src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs
IF NOT EXISTS(SELECT 1 FROM {GetLockTableName()} WHERE [Key] = @PubKey) INSERT INTO {GetLockTableName()} ([Key],[Instance],[LastLockTime]) VALUES(@PubKey,'',@LastLockTime); IF NOT EXISTS(SELECT 1 FROM {GetLockTableName()} WHERE [Key] = @RecKey) INSERT INTO {GetLockTableName()} ([Key],[Instance],[LastLockTime]) VALUES(@RecKey,'',@LastLockTime);