Move cross-instance NOTIFY behind DBAdapter.notify#4672
Draft
Move cross-instance NOTIFY behind DBAdapter.notify#4672
Conversation
Realm.#notifyFileChange was issuing raw `SELECT pg_notify(...)` SQL against this.#dbAdapter. In the host/browser context the adapter is SQLite, which has no pg_notify function — every write logged `SQLITE_ERROR: no such function: pg_notify`. The host runs a single in-process realm with no peers to notify, so issuing the SQL was also semantically a no-op even when it didn't error. Push the cross-instance broadcast capability down into the existing DBAdapter abstraction: - Add `notify(channel, payload): Promise<void>` to the DBAdapter interface, documented as best-effort cache-coherency. - PgAdapter implements via `SELECT pg_notify($1, $2)`. - SQLiteAdapter implements as a no-op (no pub/sub primitive, no peers). - Realm.#notifyFileChange calls `this.#dbAdapter.notify(...)` and no longer embeds pg-specific SQL. - Update the realm-server listener test to drive notifications via the new method (also gives PgAdapter.notify direct CI coverage). - Add `notify` to the inline DBAdapter mocks in bot-runner / realm-server / runtime-common tests. Surfaced as flaky test-log noise after PR #4660 (CS-10892: realm_file_changes NOTIFY channel) widened the call site without gating SQLite. Original diagnosis and the kind === 'sqlite' guard fix from Hassan Abdel-Rahman on cs-11036-indexer-resume-progress. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f9dcc47 to
8b212d8
Compare
…guard # Conflicts: # packages/postgres/pg-adapter.ts # packages/realm-server/tests/realm-file-changes-listener-test.ts
4 tasks
Contributor
Preview deploymentsHost Test Results 1 files 1 suites 1h 41m 19s ⏱️ Results for commit 6ee8224. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Realm.#notifyFileChangewas issuing rawSELECT pg_notify(...)SQL againstthis.#dbAdapter. In the host/browser context the adapter is SQLite, which has nopg_notifyfunction — every write loggedSQLITE_ERROR: no such function: pg_notify. The host runs a single in-process realm with no peers to notify, so issuing the SQL was also semantically a no-op even when it didn't error.This pushes the cross-instance broadcast capability down into the existing
DBAdapterabstraction:notify(channel, payload): Promise<void>to theDBAdapterinterface, documented as best-effort cache-coherency.PgAdapterimplements viaSELECT pg_notify($1, $2).SQLiteAdapterimplements as a no-op (no pub/sub primitive, no peers).Realm.#notifyFileChangecallsthis.#dbAdapter.notify(...)and no longer embeds pg-specific SQL.PgAdapter.notifydirect CI coverage).notifyto the inlineDBAdaptermocks in bot-runner / realm-server / runtime-common tests.Surfaced as flaky test-log noise after PR #4660 (CS-10892: realm_file_changes NOTIFY channel) widened the call site without gating SQLite. Original diagnosis and the simpler
kind === 'sqlite'guard fix were Hassan's, oncs-11036-indexer-resume-progress; this PR replaces that guard with the adapter-level abstraction.Test plan
no such function: pg_notifylines in the test log.realm-file-changes-listener-test.tsstill passes end-to-end against real Postgres (now exercisingPgAdapter.notify).🤖 Generated with Claude Code