Skip to content

buzz-db: move the search pool and Postgres search SQL behind buzz-db - #10091

Open
TheSentinel454 wants to merge 3 commits into
elrond/buzz-811-audit-storefrom
elrond/buzz-811-search-store
Open

TheSentinel454 wants to merge 3 commits into
elrond/buzz-811-audit-storefrom
elrond/buzz-811-search-store

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #10090. Merge that first.

Summary

buzz-search ran its own Postgres SQL and built its own search pool. The relay built that pool too. This PR moves both into buzz-db, so buzz-search reaches Postgres only through buzz-db handles.

Piece Before After
Full-text and profile-name search SQL buzz-search/src/query.rs buzz_db::search (store/search.rs)
Search statement cancellation buzz-search/src/cancel.rs buzz_db::search::cancel
Search pool built in the relay (connect_search_pool) buzz_db::SearchStore::connect
SearchService storage a raw PgPool a SearchStore
Indexer outbox claims, parking and backfill SQL inline sqlx in indexer.rs SearchOutboxStore via Db::search_outbox_store()
Outbox depth and lag gauges inline sqlx in outbox_metrics.rs SearchOutboxStore::stats

buzz-search keeps the backend choice, the OpenSearch client, the indexer loop and the result types. It re-exports the moved query types, so callers of buzz_search::* do not change. buzz-search no longer uses sqlx in production code, so sqlx moves to its dev-dependencies. SearchError::Db now wraps buzz_db::DbError.

This is the third of three steps that take raw pool access and SQL out of every crate except buzz-db. The first two move the relay, admin and deletion callers (#10087) and the audit log SQL (#10090).

What got simpler

  • buzz-search drops sqlx and buzz-datastore-tracing from its production dependencies.
  • The relay no longer builds pools: connect_search_pool and its test move into buzz-db next to the other pool constructors.
  • ARCHITECTURE.md states one rule ("every crate reaches Postgres only through buzz-db"), with the separate push gateway as the only exception.

Behavior

No behavior change. The search pool keeps its settings: lazy, the reader URL when set (else the writer URL), the configured acquire timeout, and the same per-session read statement timeout. The SQL text is unchanged.

Tests

  • search_pool_is_lazy_prefers_the_reader_and_bounds_acquire moves from the relay to buzz-db.
  • search_store_bounds_every_statement (Postgres, buzz-db) replaces buzz-search's search_pool_bounds_every_statement. It builds the pool through SearchStore::connect, so it fails if the production constructor stops installing the statement-timeout hook.
  • Relay and buzz-search tests build SearchService from SearchStore::from_pool.
  • Ran: fmt, clippy (-D warnings) on buzz-db, buzz-search and buzz-relay; unit tests for those crates; the Postgres search tests in buzz-db, buzz-search and buzz-relay that do not need OpenSearch.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: fde1848eb4908d5898133f128b6b1f6dc50937f3...cfb1548e760f6063ebf445838180cfc2d80f69b7
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability regressions found in the authorized PR range. The search refactor preserves community scoping, caller authorization, cancellation, pool timeouts, and error classification.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not run, as requested.

Generated by Codex Security Review |
Requested by: @TheSentinel454 |
Workflow run

@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 1, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 1, 2026
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-811-search-store branch from e37a5d1 to cfb1548 Compare December 1, 2026 22:50
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 1, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 1, 2026
TheSentinel454 and others added 2 commits December 1, 2026 19:10
buzz-search built its own pool and ran its own SQL: the FTS and
profile-name queries, the abandoned-search cancel, and the outbox
gauge read. The indexer reached the writer pool through Db::pool().

- The FTS query module and its cancel logic move to buzz_db::search,
  unchanged except for the error type. A SearchStore owns the search
  pool. SearchStore::connect builds it the way the relay used to.
- SearchService takes a SearchStore instead of a PgPool. buzz-search
  re-exports the query types, so callers keep their imports.
- The indexer and the outbox gauges use Db::search_outbox_store().
  The gauge read takes a Db, so the relay sampler no longer needs the
  writer pool.
- SearchError::Db holds a DbError instead of sqlx::Error.

buzz-search no longer uses sqlx in production, so it moves to its
dev-dependencies. The search pool construction test moves from the
relay to buzz-db.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
The statement-timeout check now builds its pool with
SearchStore::connect, so it fails if the production constructor stops
installing the hook. Also drop buzz-search's unused
buzz-datastore-tracing dependency, remove an orphaned relay doc
comment, and name the push gateway as the exception in ARCHITECTURE.md.

Signed-off-by: Luke Tornquist <tornquist@squareup.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-811-search-store branch from cfb1548 to 2e5febc Compare December 2, 2026 00:11
@TheSentinel454
TheSentinel454 changed the base branch from main to elrond/buzz-811-audit-store December 2, 2026 00:11
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Dec 2, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>

This branch was successfully deployed

1 active (outdated) deployment
codex-review — cfb1548e Deployed Dec 1, 2026 by TheSentinel454 via Run Codex Security Review #19101
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