In G-D we trust



DEVOPS AFTER APPLYING SOLUTION UPGRADE - PART 2


We have dynamics crm 2016 version 8.1.0.

After a second delete of many fields, we got errors updating the same solution.
the errors were:

solution With Id = old GUID Does Not Exist

There should not be more than one component instance for a solution being upgraded.  Solution id: 
'30164bce-d912-4caa-a569-39330cf7ce27'

After analyzing the error, we wrote the following code to solve or issue.
this is unsupported, and it can be done only on an on-premise environment.
Be careful and please run first at a test environment, before running on production.
 

select AttributeMapId ,OverwriteTime, CreatedOn, SolutionId ,
rank () over (partition by attributemapid order by  OverwriteTime desc) as rnk
into #tmpww
FROM AttributeMapBase 
where
solutionid='30164bce-d912-4caa-a569-39330cf7ce27' 
--and OverwriteTime ='1900-01-01 00:00:00.000'
--select * from SolutionBase where solutionid='30164bce-d912-4caa-a569-39330cf7ce27'


and AttributeMapId in (
select ptb.AttributeMapId --,OverwriteTime
from
   AttributeMapBase ptb
where
ptb.solutionid='30164BCE-D912-4CAA-A569-39330CF7CE27'
group by AttributeMapId --,OverwriteTime
having count (*) > 1
) order by AttributeMapId, OverwriteTime desc
begin transaction
DELETE from AttributeMapBase
where AttributeMapId in (
select AttributeMapId from #tmpww where rnk <> 1
) and OverwriteTime in (
select OverwriteTime from #tmpww where rnk <> 1
)
commit transaction

p.s. if you don't commit the transaction, import solution will fail retrieving  AttributeMapBase and you will get the following error:

The wait operation timed out

it won't help to extend the CRM timeout because the trace shows the sql select that fails sends a timeout of 120 seconds.

disclaimer: I'm not sure the errors were related to the solution or only one of them.

Happy CRMing

Comments