  Valued constraint satisfaction problems (VCSPs) constitute a large class of
computational optimisation problems. It was shown recently that, over finite
domains, every VCSP is in P or NP-complete, depending on the admitted cost
functions. In this article, we study cost functions over countably infinite
domains whose automorphisms form an oligomorphic permutation group. Our results
include a hardness condition based on a generalisation of pp-constructability
as known from classical CSPs and a polynomial-time tractability condition based
on the concept of fractional polymorphisms. We then observe that the resilience
problem for unions of conjunctive queries (UCQs) studied in database theory,
under bag semantics, may be viewed as a special case of the VCSPs that we
consider. We obtain a complexity dichotomy for the case of incidence-acyclic
UCQs and exemplarily use our methods to determine the complexity of a query
that had remained open in the literature. Further, we conjecture that our
hardness and tractability conditions match for resilience problems for UCQs.
