Skip to content

symfonic.capabilities.memory.mutations

mutations

One ordering point for memory publication and subtree erasure.

mutation_fence_for

mutation_fence_for(graph: Any, vectors: Any = None) -> Any

Derive the strongest fence the composed stores can honestly offer.

Source code in src/symfonic/capabilities/memory/mutations.py
def mutation_fence_for(graph: Any, vectors: Any = None) -> Any:
    """Derive the strongest fence the composed stores can honestly offer."""
    from symfonic.capabilities.memory.commit import domain_of

    domain = domain_of(graph)
    pool = domain if hasattr(domain, "raw_pool") else None
    vector_pool = getattr(vectors, "pool", None)
    if pool is not None:
        if vector_pool is not None and vector_pool is not pool:
            raise ConfigurationError(
                "graph and vector memory use different Postgres pools, so "
                "publication and erasure cannot share one ordering point"
            )
        return _PostgresMutationFence(pool)
    if vector_pool is not None:
        raise ConfigurationError(
            "graph and vector memory do not share one Postgres pool, so "
            "publication and erasure cannot share one ordering point"
        )
    if domain is not None:
        return _InProcessMutationFence(domain)
    if vectors is not None:
        raise ConfigurationError(
            "a vector-backed memory store needs a durable mutation fence; "
            f"{type(graph).__name__} publishes no pool or in-process transaction"
        )
    return _InProcessMutationFence(graph)