Upgraded plone to 5.2 instance error IntIdMissingError: z3c.relationfield.relation.RelationValue

Hello! Please help solve the problem.
I am trying to upgrade from version 5.1.6 to 5.2.7
I get the error in the next step:
/portal_setup/manage_upgrades
Upgrade Step Group
-> Run to52beta1 upgrade profile. (5201 → 5202)
-> Run to52rc1 upgrade profile. (5201 → 5202)

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 155, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 337, in publish_module
  Module ZPublisher.WSGIPublisher, line 255, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 61, in call_object
  Module Products.GenericSetup.tool, line 1088, in manage_doUpgrades
  Module Products.GenericSetup.upgrade, line 168, in doStep
  Module plone.app.upgrade.v52.betas, line 110, in to52beta1
  Module plone.app.upgrade.v52.betas, line 72, in remove_interface_indexes_from_relations_catalog
  Module zc.relation.catalog, line 564, in unindex
  Module z3c.relationfield.index, line 42, in dump
  Module five.intid.intid, line 41, in getId
  Module zope.intid, line 108, in getId
IntIdMissingError: <z3c.relationfield.relation.RelationValue object at 0xad63b22c oid 0x4b396 in <Connection at b4992dec>>

I’m getting this too on a current upgrade project. It’s probably the next thing I have to figure out so I’ll post again if I make progress.

Do you know if it is hitting this for you on a Relation field in a custom or extended content type vs an included type? For me it is not a default type it is a custom field on a type provided by an add-on.

For myself, I used the following solution, which is not correct, but works.
In the file
plone.app.upgrade/plone/app/upgrade/v52/betas.py
I commented out the line 72:

for rel in relations:
#catalog.unindex (rel) <-----------------------------
try:
catalog.index (rel)
except IntIdMissingError:
logger.warn ('Broken relation removed.')

Result log:
........
........
2019-11-17 19:08:37,903 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.
2019-11-17 19:08:37,904 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.
2019-11-17 19:08:37,905 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.
2019-11-17 19:08:37,906 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.
2019-11-17 19:08:37,907 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.
2019-11-17 19:08:37,908 WARNING [plone.app.upgrade:76][waitress] Broken relation removed.

So far, I have not found any losses and problems.

There was an error on early upgrade code to Plone 5.2, I think it was to 5.2RC1 that created errors when upgrading the relation catalog:

But this was fixed on latest version of 5.2 so you should not have any problems now.

You should upgrade your site to 5.2 directly, without going through the beta or RC versions.

I am using the latest stable version of Plone 5.2.0 (5207) which includes plone.app.upgrade 2.0.27 with corrections.
It is not possible to immediately upgrade from 5.1 to 5.2. using the fixes, all update steps are automatically performed.
This is a code error or my catalog is not standard.

Then I don't know what's going on there. I had the relations error when I tested the migration in several of our sites, and it was gone after the said changes.

I have a similar error in a similar situation: upgrading from 5.1.5 to 2.5.1. Upgrade fails with an ObjectMissingError related to intids.

 2020-06-04 13:16:14,099 ERROR   [plone.app.upgrade:299][waitress] Upgrade aborted. Error:
    Traceback (most recent call last):
      File "/opt/plone52/buildout-cache/eggs/Products.CMFPlone-5.2.1-py2.7.egg/Products/CMFPlone/MigrationTool.py", line 292, in upgrade
        step['step'].doStep(setup)
      File "/opt/plone52/buildout-cache/eggs/Products.GenericSetup-2.0.1-py2.7.egg/Products/GenericSetup/upgrade.py", line 168, in doStep
        self.handler(tool)
      File "/opt/plone52/buildout-cache/eggs/plone.app.upgrade-2.0.31-py2.7.egg/plone/app/upgrade/v52/betas.py", line 130, in to52beta1
        remove_interface_indexes_from_relations_catalog()
      File "/opt/plone52/buildout-cache/eggs/plone.app.upgrade-2.0.31-py2.7.egg/plone/app/upgrade/v52/betas.py", line 71, in remove_interface_indexes_from_relations_catalog
        relation = catalog.resolveRelationToken(token)
      File "/opt/plone52/buildout-cache/eggs/zc.relation-1.1.post2-py2.7.egg/zc/relation/catalog.py", line 726, in resolveRelationToken
        return self._relTools['load'](token, self, {})
      File "/opt/plone52/buildout-cache/eggs/z3c.relationfield-0.9.0-py2.7.egg/z3c/relationfield/index.py", line 49, in load
        return intids.getObject(token)
      File "/opt/plone52/buildout-cache/eggs/zope.intid-4.3.0-py2.7.egg/zope/intid/__init__.py", line 89, in getObject
        raise ObjectMissingError(id)
    ObjectMissingError: 356395009

The code change suggested in upgrade/v52/betas.py has been made in the copy I got via the installer.

It is suggested above that "You should upgrade your site to 5.2 directly, without going through the beta or RC versions.". How? On launching the 5.2.1 instance I get an 'Upgrade' button which walks through all the updates.