Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Chris 1 post 71 karma points
    May 15, 2019 @ 11:01

    Cannot insert duplicate key row in object 'dbo.cmsPropertyData' with unique index 'IX_cmsPropertyData_1'.


    This is one of those unreproducable occasional error in the log questions. Hoping maybe someone has encountered it.

    We are setting a custom member property and then saving that member. Every so often we see an exception updating the index. Interestingly it's not always the same value in the property type id (the 3rd value in the index). I assume saving the member saves all properties though.


    var member = _memberService.GetByEmail(model.LoginEmail);
    member.SetValue(alias, value);

    Stack Trace:

    ERROR Umbraco.Core.Persistence.UmbracoDatabase - Exception (3afecff6).
    System.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.cmsPropertyData' with unique index 'IX_cmsPropertyData_1'. The duplicate key value is (271867, 9b728635-eae4-4616-8b48-c34bd0838c77, 412).
    The statement has been terminated.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteScalar()
    at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c_DisplayClass11_0.<ExecuteScalarWithRetry>b_0()
    at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
    at Umbraco.Core.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco)

    Has anyone else seen this?

    Cheers Chris.

    Umbraco Version: 7.10.4

  • Ali 22 posts 114 karma points
    Sep 28, 2019 @ 18:06


    When I have two different member types in Member section, both with same custom property alias (of type textbox), I get that error when trying to insert value and save it using MemberService in a controller.

    Umbraco version 7.12.4

    Br Ali

  • AddWeb Solution Pvt. Ltd 109 posts 353 karma points
    Sep 30, 2019 @ 08:04
    AddWeb Solution Pvt. Ltd

    There is a duplicate value being generated / inserted in DB for unique field

  • Dave Mason 10 posts 90 karma points
    Jun 01, 2021 @ 11:16
    Dave Mason

    I don't suppose this turned out to be related to events running when saving members? Seeing something similar and mulling over raiseEvents = false.

  • Chris Dunsing 18 posts 82 karma points
    Jan 27, 2022 @ 17:18
    Chris Dunsing

    Similar issue here. Hard to understand why the issue is occurring. Dave's hint is interesting but changing the raise events made no difference in the outcome. But it is conceivable that a Login would perform an update and a Save would be coming on the heals of that. So order of calls would seem very important.

    For example: Member logs in and profile data is updated along side it.

    var member = MemberService.GetByUsername(...); //Get current version of member
     Member.Login(...);//Login - *Updates version due to change in last login date
     member.SetValue(alias, value); //updates old version due to order of calls.
     MemberService.Save(member); //creates collision because the login activity was called after the member retrieval thus making a save on an old version.

    This order of calls would create the error.

    GetByUsername Should be called AFTER Login to avoid updating an out of date version of member.

Please Sign in or register to post replies

Write your reply to: