Deploying to production: Duplicate ID error with static entity

Deploying to production: Duplicate ID error with static entity

  

We're facing a problem deploying to production. For a couple of weeks now we have an open support ticket where we ask for a solution for this issue. Since we don't hear much from support, maybe someone here can help us out. 

We have an application running in production. It uses a lot of static entities imported from a wsdl/xsd. The key for all of those static entities is a text value. Foreign keys referencing to this are on protect.

A while back we made a hotfix on production to add some new values. We manually added these records and propagated these back to TST and DEV. 

Now we've built some new functionality and we want deploy to production again. DEV to TST, no problem. When we go to PRD however, the deployment fails: "The primary key value of a record must be unique. Record MatAType.St26_9G3_4___ conflicts with a value existing on the database. Use import to recover the record or use a different value." 

The behaviour I would expect is that the platform would just ignore this record since it already exists in production. 

I've been unable to reproduce the error in a non-productive environment so I can't experiment much. It's also an enterprise cloud environment so I can't access the database directly.

Anybody here can think of something to try?



Hi Rob,


To fix that use the merge feature using the module from production againt the one in dev make the static entity match internally.

On practice since you created them manually the platform cannot confirm that thy are the same as the names can be renamed and do not guarantee identity. So the safest is to assume they are not the same.

Also if you had imported the web reference they would have matched since the automatic import ensures that internally they are always created the same way.


Regards,

João Rosado

Hi Rob.

Two things you can check.

  • do you have any of those identifiers set as a foreign key on other entities?
  • did you query the Production database to compare the values on the static entity in Service Studio and the physical table?


Forgot one thing, after merging it back the error will most likely happen on the other environments.

The information that causes it to fail is in the system entity Entity_Record. You probably will need to fix or remove the lines related (and only those) to that static entity from there. Since the key is not autonumber the platform will be able to insert back the information related to that entity.

I do not recommend doing this in production since deleting/changing information there can cause problems until the module is republished.


Regards,

João Rosado

Hi Rob,

I recently had this problem with one of the static entity in my application and tried so many things but no luck than finally i removed the entitydetails and its attribute from OS meta data entities (Ossys_entity and Ossys_enttiy_attribute) for that static entity and dropped the entity from database and republish it again and it solves the problem.



Regards

-PJ-





 

Solution

João Rosado wrote:

Forgot one thing, after merging it back the error will most likely happen on the other environments.

The information that causes it to fail is in the system entity Entity_Record. You probably will need to fix or remove the lines related (and only those) to that static entity from there. Since the key is not autonumber the platform will be able to insert back the information related to that entity.

I do not recommend doing this in production since deleting/changing information there can cause problems until the module is republished.


Regards,

João Rosado

Hi João, thanks for your answer. I did not know about the entity_record table, so this helped me a lot! Like you said the merge functionality produced the same error when deploying the module. 

However with your help, I've been able to use the merge functionality (from PRD to TST) by manually updating the affected records of Entity_Record in the TST environment. (is_active=false) The records now have the same internal id, so I'm fairly positive a new deployment to PRD will no longer give me the same error. 


edit: @João Rosado the deployment succeeded. :)




Solution

Pramod Jain wrote:

Hi Rob,

I recently had this problem with one of the static entity in my application and tried so many things but no luck than finally i removed the entitydetails and its attribute from OS meta data entities (Ossys_entity and Ossys_enttiy_attribute) for that static entity and dropped the entity from database and republish it again and it solves the problem.



Regards

-PJ-





 

Thanks, if my other attempts fail I will give this a try;) Since the keys of the static entity are also static text this might work!