Currently, it is possible for a user to upload a file to Commons that is identical to one on a local project, or vice versa. We can detect it through analytical queries on the Cloud-Services wikireplica servers, by matching the img_sha1 value of the files in the image table in each of those two databases.
This query may fail once the changes to Replicas are implemented , as it won't be possible to join tables cross-wiki as is done here. (see https://lists.wikimedia.org/pipermail/cloud/2020-November/001290.html and https://wikitech.wikimedia.org/wiki/News/Wiki_Replicas_2020_Redesign)
This query is useful because in some cases, the redundant file has a different name (so T267992 will not find it). The real goal here is to (a) remove redundeat photos, and (b) in cases where one file is identified to be a copyright violation, notify the other community about it too. The latter happens sometimes for fawiki, for instance, where I find a copyvio issue with a file that was also uploaded to Commons so I tag them for deletion in Commons as well.
Note that this doesn't need a real-time replica; one option might be to create a separate data store that contains a daily or weekly dump of the images table for all wikis.