Okay, so I had my replica globalid population corrupted by the failure of arcpy.da.InsertCursor to honor arcpy.env.preserveGlobalIds, and a search turned this up, so I needed to engineer a solution.
If there's only a few features, and a reliable key column, you could use an array to store up key_col(s),globalid list of lists to issue an UPDATE via an arcpy.ArcSDESQLExecute cursor but I have widely disparate row counts in several score of tables, and sending 30M UPDATE commands is not the most efficient way to attack this problem (at only 6ms per UPDATE that's 50 hours wasted).
What I've settled on is populating parallel tables with the primary key column(s) plus globalid as a VARCHAR(38) column, then running a single update:
UPDATE schema.tablename_t1 t
SET globalid = vt.globalid
FROM (
SELECT t1.objectid,g1.globalid
FROM schema.tablename_g1 g1
JOIN schema.tablename_t1 t1 USING (keycolumns)
) vt
WHERE t.objectid = vt.objectid
Notes:
- This won't work with versioned tables (I need to populate these tables before enabling versioning, so I'm good)
- You need to use an arcpy.da.Editor to populate the tables in parallel (two open DA cursors on the same connection won't work without it)
- I drive the inner virtual table query from the G1 to the T1, because then I don't have to index both tables, just T1 (which I need to index anyway).
- Don't forget to TRUNCATE the g1 table contents or DROP a standalone temp table after the UPDATE.
- V