anchor.diff:          throw(Error)
       end,
   
  -    % provider supports are recalculated asynchronously - wait for it before
  -    % returning to avoid race conditions when providers try to fetch the space
  -    % entity, but they are not yet recognized as effective supporters and declined
  -    utils:wait_until(fun() ->
  -        space_logic:is_supported_by_provider(SpaceId, ProviderId) andalso
  -            provider_logic:supports_space(ProviderId, SpaceId)
  -    end),
  +    wait_for_eff_support_recalculation(ProviderId, SpaceId),
   
       NewGRI = #gri{type = od_space, id = SpaceId, aspect = instance, scope = protected},
       {true, {Space, Rev}} = space_logic_plugin:fetch_entity(NewGRI),
  
positive.code:                 fun(ExistingStats) ->
                      harvester_indices:coalesce_index_stats(ExistingStats, SpaceId, ProviderId, true)
                  end)
          end, UpdatedDoc#document.value#od_space.harvesters)
      end.
  
  
  
negative.code:         <<"storageId">> => StorageId,
          <<"providerId">> => ProviderId
      }.
  
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Provider supports are recalculated asynchronously - wait for it so that
  %% the information about current supports is up to date when this function returns.
  %% @end
  %%--------------------------------------------------------------------
  -spec wait_for_eff_support_recalculation(od_provider:id(), od_space:id()) -> ok.
  wait_for_eff_support_recalculation(ProviderId, SpaceId) ->
      try
          utils:wait_until(fun() ->
              space_logic:is_supported_by_provider(SpaceId, ProviderId) andalso
                  provider_logic:supports_space(ProviderId, SpaceId)
          end)
      catch _:_ ->
          % Do not fail upon timeout; if there are too many pending changes in the graph,
          % this may take even longer. Worst case scenario is that the client will get
          % a confirmation of support change operation, but the effective supports will
          % not yet be recalculated. They will converge eventually though.
          ok
      end.
  