Sweeping !46528 from master to 22.0-mc20. GeneratorObjects: Fix potential race. See merge request !46553