52One Postgres, every process — the catalog and the broker in production
Verbs:[catalog.postgres] · [broker.postgres] · jammi.testing.LiveServer · get_server_info · add_source · generate_embeddings · search · register_topic · publish_topic · subscribe_collect · Background: one database as the system of record every process reads and writes, and an append-only log it replays (Kleppmann 2017; Kreps, Narkhede, and Rao 2011) · Checked: measurement (what one process wrote, another reads back row for row; every event one process publishes, another receives).
The other chapters run on the development default: a SQLite catalog file and an in-process broker. That default is single-process by construction — one engine owns the file. A deployment with more than one process (a server and a batch job, two server replicas, a worker fleet) runs its catalog and its broker on Postgres instead: the catalog’s rows (sources, models, result tables, jobs) live in one database every process shares, and the broker is Postgres LISTEN/NOTIFY over the topics’ own backing tables, which live in that same database. Nothing else changes — the same binary, the same verbs; the deployment is configuration.
This chapter runs that deployment in one runtime: a Postgres installed with pip (pgserver), a jammi-server process, and an embedded engine in this notebook’s own process, both configured onto the same database.
import tempfileimport threadingfrom pathlib import Pathimport jammiimport pgserverimport pyarrow as pafrom jammi.testing import LiveServerfrom jammi_cookbook import fixturesfrom jammi_cookbook.claims import claimMODEL = fixtures.model("tiny_bert")CORPUS = fixtures.url("tiny_corpus.parquet")QUERY ="how does quantum computing work?"work = Path(tempfile.mkdtemp())postgres = pgserver.get_server(work /"pgdata")ARTIFACTS = work /"artifacts"def catalog_url(postgres) ->str:"""The engine's URL for `postgres`: the libpq URI it hands out, reached over its Unix socket (an empty host, the socket directory in `host`)."""return postgres.get_uri()
/__w/jammi-ai/jammi-ai/.venv/lib64/python3.12/site-packages/platformdirs/api.py:459: RuntimeDirWarning: XDG_RUNTIME_DIR is not set, falling back to /tmp/runtime-0
return Path(self.user_runtime_dir)
52.1 The configuration: one database, two roles
The catalog stanza names the database — here over its Unix socket, in the libpq form Postgres hands out (an empty host, the socket directory in host); the broker stanza names no URL of its own, so it uses the catalog’s — one Postgres serves both roles. idle_poll_secs bounds how long a subscriber waits for a wake-up it might have missed.
config = work /"jammi.toml"config.write_text(f"""[catalog.postgres]url = "{catalog_url(postgres)}"[broker.postgres]idle_poll_secs = 1[gpu]device = -1""")print(config.read_text())
The server process registers a source and embeds it. The embedded engine — a different process, opened on the same configuration — sees the source, sees the embedding table, and searches it: the rows it gets are the rows the server gets.
def ranked(db) ->list[tuple[str, float]]: query = db.encode_query(model=MODEL, query=QUERY) hits = db.search("corpus", query=query, k=5).to_pylist()return [(hit["_row_id"], round(hit["similarity"], 6)) for hit in hits]with LiveServer(ARTIFACTS, env={"JAMMI_CONFIG": str(config)}) as server, \ jammi.connect(server.endpoint) as remote: remote.add_source("corpus", url=CORPUS, format="parquet") table = remote.generate_embeddings( source="corpus", model=MODEL, columns=["content"], key="id", modality="text") served = ranked(remote) server_broker = remote.get_server_info()["broker"]with jammi.connect(f"file://{ARTIFACTS}", config=str(config)) as local: seen = [t["table_name"] for s in local.list_sources() for t in s["result_tables"]] embedded = ranked(local) local_broker = local.get_server_info()["broker"]print(f"broker: server={server_broker}, embedded={local_broker}")print(f"the embedded engine sees the server's table: {table in seen}")for (key, score), (key_e, score_e) inzip(served, embedded):print(f" {key:>8}{score:.6f}{key_e:>8}{score_e:.6f}")
2026-10-03T07:44:37.427453Z WARN jammi_kernels::admission: fused-kernel domain check failed; falling back to the eager composition op="attention_block_fused" predicate="head_dim_is_attention_block_fixed_head_dim"
claim("both processes run on the shared Postgres catalog and broker", server_broker == local_broker =="postgres")claim("the embedded engine sees the table the server made", table in seen)claim("and its search returns exactly the server's rows and scores", served == embedded,f"{len(embedded)} rows")
✓ both processes run on the shared Postgres catalog and broker
✓ the embedded engine sees the table the server made
✓ and its search returns exactly the server's rows and scores (5 rows)
The embedded engine did not copy anything and was not told about the table: it read the same result_tables row from the same database, and the same Parquet the row names, from the same result root.
52.3 Events across processes
A topic’s backing table is a table in the catalog database, and the Postgres broker wakes every subscriber — in any process — when a publish commits. So one process publishes and another receives. Here a subscriber in the server process waits for three batches while the embedded engine publishes them.
SCHEMA = pa.schema([("op", pa.string()), ("key", pa.string())])batches = [ pa.table({"op": ["add", "add"], "key": ["a", "b"]}, schema=SCHEMA), pa.table({"op": ["update"], "key": ["a"]}, schema=SCHEMA), pa.table({"op": ["delete", "add"], "key": ["b", "c"]}, schema=SCHEMA),]with LiveServer(ARTIFACTS, env={"JAMMI_CONFIG": str(config)}) as server, \ jammi.connect(server.endpoint) as remote: remote.register_topic("changes", schema=SCHEMA) received = {}def subscribe() ->None: received["live"] = remote.subscribe_collect("changes", from_offset=0, replay_only=False, max_batches=len(batches)) subscriber = threading.Thread(target=subscribe) subscriber.start()with jammi.connect(f"file://{ARTIFACTS}", config=str(config)) as local: offsets = [local.publish_topic("changes", batch=b) for b in batches] subscriber.join(timeout=60) replay = remote.subscribe_collect("changes", from_offset=0)live = received["live"]published = pa.concat_tables(batches)print(f"published at offsets {offsets}: {published.num_rows} events")print(f"received live in the server process: {live.num_rows} events")print(f"replayed from the backing table: {replay.num_rows} events")
published at offsets [0, 1, 2]: 5 events
received live in the server process: 5 events
replayed from the backing table: 5 events
claim("each publish takes the next offset", offsets == [0, 1, 2])claim("the subscriber in the other process receives every event, in order, and returns",not subscriber.is_alive() and live.select(["op", "key"]).equals(published),f"{live.num_rows} events")claim("and a replay reads them back as published", replay.select(["op", "key"]).equals(published))
✓ each publish takes the next offset
✓ the subscriber in the other process receives every event, in order, and returns (5 events)
✓ and a replay reads them back as published
The live subscriber and the replay agree because they are the same thing: NOTIFY only says go look; what the subscriber delivers comes from replaying the backing table from its offset. A subscriber in a process that missed a wake-up — or started after the publish — reads the same rows on its next poll.
2026-10-03T07:44:37.631002Z WARN jammi_db::trigger::postgres: postgres broker: listener error; waking every topic and retrying error=error communicating with database: No such file or directory (os error 2)
52.4 What this shows
One database is the system of record. A server and an embedded engine configured onto the same Postgres see one catalog: what one registers or computes, the other reads, with no copy and no coordination beyond the database (Kleppmann 2017).
The broker adds no service. Topics are tables in that database; LISTEN/NOTIFY is a wake-up, and the log a subscriber reads is the backing table — so delivery across processes is a replay, and a missed wake-up costs latency, never data (Kreps, Narkhede, and Rao 2011).
Deployment is configuration. Nothing in the program changed between the single-process chapters and this one except the two stanzas above.
The next chapter operates this deployment: backing it up and restoring it, and reading what it reports about its own health.
Kleppmann, Martin. 2017. Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems. O’Reilly Media.
Kreps, Jay, Neha Narkhede, and Jun Rao. 2011. “Kafka: A Distributed Messaging System for Log Processing.” In Proceedings of the NetDB Workshop on Networking Meets Databases, 1–7.