def _process_multisync_replication(self) -> None:
        """Process synchronous replication state with one or more sync standbys.

        Synchronous standbys are registered in two places postgresql.conf and DCS. The order of updating them must
        be right. The invariant that should be kept is that if a node is primary and sync_standby is set in DCS,
        then that node must have synchronous_standby set to that value. Or more simple, first set in postgresql.conf
        and then in DCS. When removing, first remove in DCS, then in postgresql.conf. This is so we only consider
        promoting standbys that were guaranteed to be replicating synchronously.
        """
        sync = self._maybe_enable_synchronous_mode()
        if not sync:
            return

        current_state = self.state_handler.sync_handler.current_state(self.cluster)
        picked = current_state.active
        allow_promote = current_state.sync_confirmed
        voters = CaseInsensitiveSet(sync.voters)

        if picked == voters and voters != allow_promote:
            logger.warning('Inconsistent state between synchronous_standby_names = %s and /sync = %s key '
                           'detected, updating synchronous replication key...', list(allow_promote), list(voters))
            sync = self.dcs.write_sync_state(self.state_handler.name, allow_promote, 0, version=sync.version)
            if not sync:
                return logger.warning("Updating sync state failed")
            voters = CaseInsensitiveSet(sync.voters)

        if picked == voters == current_state.sync and current_state.numsync == len(picked):
            return

        # update synchronous standby list in dcs temporarily to point to common nodes in current and picked
        sync_common = voters & allow_promote
        if sync_common != voters:
            logger.info("Updating synchronous privilege temporarily from %s to %s",
                        list(voters), list(sync_common))
            sync = self.dcs.write_sync_state(self.state_handler.name, sync_common, 0, version=sync.version)
            if not sync:
                return logger.info('Synchronous replication key updated by someone else.')

        # When strict mode and no suitable replication connections put "*" to synchronous_standby_names
        if global_config.is_synchronous_mode_strict and not picked:
            picked = CaseInsensitiveSet('*')
            logger.warning("No standbys available!")

        # Update postgresql.conf and wait 2 secs for changes to become active
        logger.info("Assigning synchronous standby status to %s", list(picked))
        self.state_handler.sync_handler.set_synchronous_standby_names(picked)

        if picked and picked != CaseInsensitiveSet('*') and allow_promote != picked:
            # Wait for PostgreSQL to enable synchronous mode and see if we can immediately set sync_standby
            time.sleep(2)
            allow_promote = self.state_handler.sync_handler.current_state(self.cluster).sync_confirmed

        if allow_promote and allow_promote != sync_common:
            if self.dcs.write_sync_state(self.state_handler.name, allow_promote, 0, version=sync.version):
                logger.info("Synchronous standby status assigned to %s", list(allow_promote))
            else:
                logger.info("Synchronous replication key updated by someone else")
Process synchronous replication state with one or more sync standbys.

        Synchronous standbys are registered in two places postgresql.conf and DCS. The order of updating them must
        be right. The invariant that should be kept is that if a node is primary and sync_standby is set in DCS,
        then that node must have synchronous_standby set to that value. Or more simple, first set in postgresql.conf
        and then in DCS. When removing, first remove in DCS, then in postgresql.conf. This is so we only consider
        promoting standbys that were guaranteed to be replicating synchronously.
        
patroni/ha.py