Backport relation merger updates from 9675c7d to 4-0-stable

Fixes #10995.
Merge pull request #12759 from dmarkow/backport-9675c7d

Backport relation merger updates from 9675c7d to 4-0-stable