mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
chore(push): retire push notification database trigger (#8352)
Buzz must schedule mobile push notifications when it saves an eligible message. The relay, the server that receives and stores messages, now does this in application code. An older database trigger still exists. This trigger is a rule that runs automatically when a message is saved. This PR removes the old trigger and its supporting database function. The relay remains responsible for scheduling notifications. Migration 0063 makes this change in existing databases; updated setup scripts apply it to new databases. The change does not turn on push notifications. Production migration and deployment need separate approval. Before deployment, verify the release images and all pending database migrations. If push needs to be stopped after release, disable it with the feature flag and keep the qualified application version and database schema. Do not downgrade the application image. ### Validation - Local checks passed: 519 isolated database integration tests, 166 database unit tests, 17 source-policy tests, and the relay push-runtime tests. - Tests verify that the migration removes the old trigger, preserves earlier migration records, and lets the application schedule push work correctly. A concurrency test exercises the real application path; deliberately removing its lock makes the test fail. - [Current-head CI passed on retry](https://github.com/block/buzz/actions/runs/38752849383/attempts/2). The first attempt had one database-connection timeout during test setup; the failed jobs passed when rerun on the unchanged commit. - Initial local CI and push checks hit unrelated ACP test failures, which passed when run separately. Only the Rust-test push hook was skipped under the repository's local-check exception; other applicable hooks passed. ### Before merge - [x] Migration 0063 is available and the push trigger remains on [main at5397ea4](5397ea49e2). Recheck if main advances before merge. --------- Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
-- T1b push gate (migrations 0023 and 0059). Enqueue only when the
|
||||
-- community has an active, endpoint-enabled, unexpired lease; the shared
|
||||
-- advisory lock pairs with the exclusive lock taken by lease activations
|
||||
-- (crates/buzz-db/src/push.rs) to close the lost-wake race.
|
||||
CREATE FUNCTION enqueue_push_match_job() RETURNS trigger
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
-- Legacy connections without the setting preserve their existing behavior.
|
||||
-- Updated writer pools always set it, including on reconnect. Check before
|
||||
-- taking push locks or touching leases/queues so disabled chat stays healthy.
|
||||
IF COALESCE(current_setting('buzz.push_async_enqueue', true), '') = 'on' THEN
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
IF NOT COALESCE(NULLIF(current_setting('buzz.push_enabled', true), '')::boolean, true) THEN
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
-- Keep this allowlist identical to the relay's validated NIP-PL descriptor.
|
||||
-- This compatibility path covers legacy writers until they are replaced.
|
||||
IF NEW.kind IN (9, 40002, 45001, 45003) THEN
|
||||
PERFORM pg_advisory_xact_lock_shared(
|
||||
hashtextextended('buzz_push_gate:' || NEW.community_id::text, 0));
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM push_leases
|
||||
WHERE community_id = NEW.community_id
|
||||
AND active
|
||||
AND endpoint_enabled
|
||||
AND expires_at > EXTRACT(EPOCH FROM now())::bigint
|
||||
) THEN
|
||||
INSERT INTO push_match_queue (community_id, event_id)
|
||||
VALUES (NEW.community_id, NEW.id)
|
||||
ON CONFLICT DO NOTHING;
|
||||
END IF;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END
|
||||
$$;
|
||||
@@ -64,7 +64,6 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
|
||||
-- functions
|
||||
\i functions/channels_community_id_immutable.sql
|
||||
\i functions/enqueue_push_match_job.sql
|
||||
\i functions/refresh_channel_ttl_after_event_insert.sql
|
||||
\i functions/guard_channel_roster_snapshot.sql
|
||||
\i functions/events_created_at_floor_guard.sql
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
CREATE TRIGGER events_enqueue_push_match
|
||||
AFTER INSERT ON events
|
||||
FOR EACH ROW EXECUTE FUNCTION enqueue_push_match_job();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER events_refresh_channel_ttl
|
||||
AFTER INSERT ON events
|
||||
DEFERRABLE INITIALLY DEFERRED
|
||||
|
||||
Reference in New Issue
Block a user