Nightly job failed on execution of [Search.Cache].[Private.UpdateCache] or [Search.Cache].[Public.UpdateCache]

17 views
Skip to first unread message

Moisey Gruzman

unread,
Dec 5, 2023, 1:52:48 PM12/5/23
to ProfilesRNS
We have 3-5 failures per month complaining about dup record in temp table:
Violation of PRIMARY KEY constraint 'PK__#NodePre__390E9BB8DAD27D5F'. Cannot insert duplicate key in object 'dbo.#NodePrefix'. The duplicate key value is (07/01/2021, 230746788).
I've verified procudere was trying to insert key and value already inserted into #Node.
Looking into code of procedure see insert into this temp table been done with (nolock) specification and this may be the couse of the failure.
Possible solution as we see:
- remove (nolock);
- prevent duplication by adding check for already existed like:
create table #Node (
                                NodeID bigint primary key
                )
                insert into #Node
                                select distinct NodeID
                                from [RDF.].[Node] n with (nolock)
                                where ViewSecurityGroup = -1
                                and not exists (select * from #Node a
                                                                                   where n.nodeid =a.nodeid)
                --[6776391 in 00:00:05]
                delete n
                                from #Node n
                                                inner join [RDF.].[Triple] t with (nolock)
                                                                on n.NodeID = t.Reitification;
We'd like to know your opinion about posible solution for the issue. 
Reply all
Reply to author
Forward
0 new messages