Cyclic mappings with an excluded foreign key under an embedded array will be missing

XMLWordPrintableJSON

    • Type: Sub-task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Issue Status as of May 14, 2026

      ISSUE DESCRIPTION AND IMPACT
      If a table is mapped to more than one collection in the target schema, then it may be cyclic. For cyclic mappings embedded under an array where any join field in the mapping is excluded, the entire object will be missing.

      1. What is a cyclic mapping?
        Relational Migrator creates a graph representing the relationship between all tables, such that each edge signifies a mapping in the chosen MongoDB schema. A mapping is cyclic if it creates a cycle in the graph. This is only possible if the mapping’s source table is used in multiple mappings. Importantly, a mapping can still be cyclic even if the same table isn’t mapped to the same collection more than once. E.g. if you have two collections:

      This has a cycle in the table graph as the tables are dependent on each other as Table A -> Table B -> Table A , so the embedded document mappings in either collection could be marked as cyclic based on which one Relational Migrator (RM) processes second.

      The simplest example is if the source database looked like the below. Note that ‘employees’ has a foreign key to itself on the ‘reports_to’ field, signifying that each employee can report to another employee.

      The following collection schema would contain the bug. The ‘employee_benefits’ table is the new document mapping, with an embedded array of all the employees that have this benefit. The name of the other employee that each employee reports to is inside ‘employeeCyclic’. This mapping is marked as cyclic since the relationship between the tables is employee_benefits -> employees -> employees. Observe that the foreign key of employees, ‘employee_id’, is excluded in ‘employeeCyclic’.

      In this case, ‘employeeCyclic’ would always be an empty object, even if there are employees that report to someone else.

      DIAGNOSIS AND AFFECTED VERSIONS
      Present in RM v1.14.1 through v1.15.2 (inclusive). The issue is fixed in v1.15.3.

      • Running verification after the migration would have detected any data integrity issues. Please note that verification is currently only possible after a migration.
      • You would only be affected if you have embedded the same table multiple times in the schema. You may detect whether your schema has any cyclic mappings by starting a migration to a dev cluster and checking what collections are created by RM. If you see any collections named
      • “_<sourceTable><collectionName><path.to.mapping>-Cache”, you can use that to find the cyclic mapping. If the mapping is nested under an embedded array with a foreign key being included, then you may have been affected. Note these cache collections are dropped at the end of the migration.
      • Alternatively, you may check whether all documents in a collection have empty or non-existent embedded objects where not expected.

      REMEDIATION AND WORKAROUNDS
      The only way to fix this would be to upgrade to v1.15.3+ and re-migrate the affected collections.
      Please feel free to open a MongoDB support ticket for direct assistance.

        1. Screenshot 2026-05-14 at 2.32.26 pm.png
          78 kB
          Marian Derias
        2. Screenshot 2026-05-14 at 2.32.33 pm.png
          134 kB
          Marian Derias
        3. Screenshot 2026-05-14 at 2.32.39 pm.png
          193 kB
          Marian Derias

            Assignee:
            Unassigned
            Reporter:
            Marian Derias
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: