def effective_configuration(self) -> CaseInsensitiveDict:
        """It might happen that the current value of one (or more) below parameters stored in
        the controldata is higher than the value stored in the global cluster configuration.

        Example: max_connections in global configuration is 100, but in controldata
        `Current max_connections setting: 200`. If we try to start postgres with
        max_connections=100, it will immediately exit.
        As a workaround we will start it with the values from controldata and set `pending_restart`
        to true as an indicator that current values of parameters are not matching expectations."""

        if self._postgresql.role == PostgresqlRole.PRIMARY:
            return self._server_parameters

        options_mapping = {
            'max_connections': 'max_connections setting',
            'max_prepared_transactions': 'max_prepared_xacts setting',
            'max_locks_per_transaction': 'max_locks_per_xact setting'
        }

        if self._postgresql.major_version >= 90400:
            options_mapping['max_worker_processes'] = 'max_worker_processes setting'

        if self._postgresql.major_version >= 120000:
            options_mapping['max_wal_senders'] = 'max_wal_senders setting'

        data = self._postgresql.controldata()
        effective_configuration = self._server_parameters.copy()

        param_diff = CaseInsensitiveDict()
        for name, cname in options_mapping.items():
            value = parse_int(effective_configuration[name])
            if cname not in data:
                logger.warning('%s is missing from pg_controldata output', cname)
                continue

            cvalue = parse_int(data[cname])
            if cvalue is not None and value is not None and cvalue > value:
                effective_configuration[name] = cvalue
                logger.info("%s value in pg_controldata: %d, in the global configuration: %d."
                            " pg_controldata value will be used. Setting 'Pending restart' flag", name, cvalue, value)
                param_diff[name] = get_param_diff(cvalue, value)
        self._postgresql.set_pending_restart_reason(param_diff)

        # If we are using custom bootstrap with PITR it could fail when values like max_connections
        # are increased, therefore we disable hot_standby if recovery_target_action == 'promote'.
        if self._postgresql.bootstrap.running_custom_bootstrap:
            disable_hot_standby = False
            if self._postgresql.bootstrap.keep_existing_recovery_conf:
                disable_hot_standby = True  # trust that pgBackRest does the right thing
            # `pause_at_recovery_target` has no effect if hot_standby is not enabled, therefore we consider only 9.5+
            elif self._postgresql.major_version >= 90500 and self._recovery_params:
                pause_at_recovery_target = parse_bool(self._recovery_params.get('pause_at_recovery_target'))
                recovery_target_action = self._recovery_params.get(
                    'recovery_target_action', 'promote' if pause_at_recovery_target is False else 'pause')
                disable_hot_standby = recovery_target_action == 'promote'

            if disable_hot_standby:
                effective_configuration['hot_standby'] = 'off'

        return effective_configuration
It might happen that the current value of one (or more) below parameters stored in
        the controldata is higher than the value stored in the global cluster configuration.

        Example: max_connections in global configuration is 100, but in controldata
        `Current max_connections setting: 200`. If we try to start postgres with
        max_connections=100, it will immediately exit.
        As a workaround we will start it with the values from controldata and set `pending_restart`
        to true as an indicator that current values of parameters are not matching expectations.
patroni/postgresql/config.py