Skip to content

Propagate events between instances sharing a database - #31

Merged
mattn merged 2 commits into
mainfrom
feat/notifier
Sep 15, 2026
Merged

mattn merged 2 commits into
mainfrom
feat/notifier

Conversation

@mattn

@mattn mattn commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Bumps relayer to v2.3.1 and eventstore to v0.17.14.

relayer now delivers events across instances through eventstore.Notifier (fiatjaf/relayer#167, fiatjaf/relayer#168), and eventstore implements it for PostgreSQL with LISTEN/NOTIFY (fiatjaf/eventstore#77). relayStore wraps the backend in an interface value, which hides Notifier the same way it hid Counter, so this re-exposes it when the backend has one — and only then, since relayer routes every delivery through a Notifier when present, and exposing one that can't listen would make NewServer fail for sqlite3 and friends.

Verified with two nostr-relay -driver postgresql processes on one Postgres: nak req --stream on both, nak event to each; a small event and a 9000-byte one (over the pg_notify limit, announced by id) arrive on both.

Note: starting several processes at once against an empty database can race on the schema creation in eventstore's Init (CREATE OR REPLACE FUNCTION from two connections → duplicate key value violates unique constraint "pg_proc_proname_args_nsp_index"). That's pre-existing and only bites on first boot; start one instance first, or run migrations ahead of scaling out.

relayer v2.3.1 delivers events across instances through
eventstore.Notifier, which eventstore v0.17.14 implements for
PostgreSQL with LISTEN/NOTIFY. Wrapping the backend in relayStore hid
that interface, so expose it again when the backend has one; keep it
hidden otherwise, since relayer routes every delivery through it when
present.

With -driver postgresql, several nostr-relay processes on one database
now push each other's events to their subscribers.
@mattn
mattn merged commit dcab9db into main Sep 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant