Repository navigation
perf(db): hydrate search hits with exact event timestamps - #9126
Conversation
Signed-off-by: Jemiah Westerman <[email protected]>
🔐 Codex Security Review
Review SummaryOverall Risk: NONE
FindingsNo concrete security, correctness, or reliability findings were identified. Notes
Generated by Codex Security Review | |
TheSentinel454
left a comment
There was a problem hiding this comment.
🤖 Partition-key correctness checks out. All three hydrators key on SearchHit.created_at, which comes from EXTRACT(EPOCH FROM created_at)::bigint on the same events row. Every production writer stores whole seconds, so the round-trip is exact. The channel-create replay binds the timestamp its own INSERT stores. No caller gets close to the 500-pair cap.
One P1: the new source-policy test binary isn't wired into CI. Two comments are optional: plan-cache persistence and a dead routed method. Reviewed at bcd41d3.
…ration The only remaining callers were two runtime routing tests. Move them to get_events_by_ids_at_routed so a single routed hydrator remains, delete the old method, and drop the source-policy test that guarded against drift between the two copies. Signed-off-by: Jemiah Westerman <[email protected]> Co-authored-by: Son of Anton <8e0ef2ab02d69a7ac089ef5eca90d1a3fbbdc546f6322dc34d0c4f3deecea7f4@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]>
crates/buzz-db/tests/event_hydration_source.rs was its own test binary, but CI's infra-free lane (justfile, scripts/run-tests.sh) runs only `--test observability_source`, so the policy never executed. Move the surviving test into observability_source.rs and delete the extra binary, so no lane list needs to change. Signed-off-by: Jemiah Westerman <[email protected]> Co-authored-by: Son of Anton <8e0ef2ab02d69a7ac089ef5eca90d1a3fbbdc546f6322dc34d0c4f3deecea7f4@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cached prepared statements may flip to a generic plan after five runs. On PG16+ a generic plan prunes `events` partitions only at executor startup, after every partition and index is already locked, defeating the lock-pressure goal. The hydration SQL text also varies with batch size, so each size would occupy its own slot in the 100-entry statement cache. Use `.persistent(false)` (as buzz-search's query already does) on the hydration lookup and on the fixed-text channel-create resend query. Add a pg_locks assertion on the real `lookup_on` path, run repeatedly on one session, proving only the requested events_p* partitions are locked; it fails when the lookup is persistent. Rename the EXPLAIN test and drop its generic-plan arm, which only reported executed relations, not locks. Signed-off-by: Jemiah Westerman <[email protected]> Co-authored-by: Son of Anton <8e0ef2ab02d69a7ac089ef5eca90d1a3fbbdc546f6322dc34d0c4f3deecea7f4@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflict in store/event.rs: keep get_events_by_ids_routed deleted. Port main's route_read changes (fallible route_read; release the reader before the writer re-run) onto the exact-key hydrator in store/event_hydration.rs, its only remaining routed by-id hydrator. Signed-off-by: Jemiah Westerman <[email protected]> Co-authored-by: Son of Anton <8e0ef2ab02d69a7ac089ef5eca90d1a3fbbdc546f6322dc34d0c4f3deecea7f4@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]>
TheSentinel454
left a comment
There was a problem hiding this comment.
🤖 Approving at e74abf3 on behalf of @TheSentinel454.
* origin/main: perf(db): hydrate search hits with exact event timestamps (#9126) perf(db): prune post-commit push enqueue by signed event timestamp (#9128) perf(db): use exact event timestamps for transactional deletion (#9130) perf(redis): index mesh ready records and share one Redis connection (#9113) fix(mobile): delay iOS message actions until a deliberate hold (#9049) Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> Signed-off-by: Will Pfleger <[email protected]> # Conflicts: # Cargo.lock
…-log-ws-writes * origin/main: fix(mobile): find verified people who have no profile (#9086) feat(protocol): define compact membership discovery (BUZZ-615) (#9117) perf(db): hydrate search hits with exact event timestamps (#9126) perf(db): prune post-commit push enqueue by signed event timestamp (#9128) perf(db): use exact event timestamps for transactional deletion (#9130) perf(redis): index mesh ready records and share one Redis connection (#9113) fix(mobile): delay iOS message actions until a deliberate hold (#9049) feat(cli): user status expiry and status read (#8777) feat(cli): send a thread message to the channel (#8778) feat(relay): add kind 30180 custom emoji entry (#8783) feat(cli): read-only unread state (NIP-RS) (#8789) feat(cli): report a message to relay moderators (#8829) buzz-db: read explicit #h sets one channel at a time (#9110) feat(cli): list huddles and their participants (#8830) docs(agents): add open-source boundary and drop private repo list (#9114) fix(mobile): answer push snapshot bridge calls at user-initiated QoS; report hop latency on callback timeout (#8916) test(mobile): lock in invite-page and bare-host community link entry (#9047) fix(desktop): keep an own send out of the frozen timeline tail (#9095) fix(db): end each table's maintenance transaction before the next (#9096) Signed-off-by: Will Pfleger <[email protected]>
* origin/main: (54 commits) release(mobile): push candidate tags as the operator, not the App (#9084) test(mobile): check posterless video previews renew the relay assertion (#9144) feat(relay): log WebSocket EVENT writes on the access target (#9154) perf(db): plan multi-value #d reads with their values (#9131) fix(mobile): confirm before starting a Huddle from the header (#9155) feat(cli): send NIP-FI evidence via credential chain and Buzz desktop (#8999) fix(mobile): find verified people who have no profile (#9086) feat(protocol): define compact membership discovery (BUZZ-615) (#9117) perf(db): hydrate search hits with exact event timestamps (#9126) perf(db): prune post-commit push enqueue by signed event timestamp (#9128) perf(db): use exact event timestamps for transactional deletion (#9130) perf(redis): index mesh ready records and share one Redis connection (#9113) fix(mobile): delay iOS message actions until a deliberate hold (#9049) feat(cli): user status expiry and status read (#8777) feat(cli): send a thread message to the channel (#8778) feat(relay): add kind 30180 custom emoji entry (#8783) feat(cli): read-only unread state (NIP-RS) (#8789) feat(cli): report a message to relay moderators (#8829) buzz-db: read explicit #h sets one channel at a time (#9110) feat(cli): list huddles and their participants (#8830) ... Signed-off-by: Taylor Ho <[email protected]>
Summary
Keep each search hit's existing signed
created_atalongside its event ID during canonical hydration. WebSocket search, HTTP search, and profile-name search now use a bounded exact-pair database lookup so PostgreSQL can prune unrelated event months. Also constrain channel-create replay detection by the timestamp of the already-available signed event.Scope / compatibility
just ci, 220 unit/source-policy tests, and the full 722-test buzz-db/search PostgreSQL suite. All three temporary timestamp-constraint mutations were killed by functional/plan assertions and restored.main.Verification
buzz-db,buzz-search, andbuzz-relaylibrary/tests.EXPLAIN ANALYZE BUFFERSof production hydration SQL verifies only requested event months execute under forced custom and generic plans, including the full 500-distinct-pair shape. A wrong-timestamp decoy detects cross-product matching.-D warnings, formatting, diff checks, PostgreSQL discovery, and differential file-size checks passed.No production latency improvement or workload-percentage claim is made.