Skip to content

storage/gcp/antispam: add optional SpannerClient to AntispamOpts#1054

Merged
AlCutter merged 1 commit into
transparency-dev:mainfrom
eperrine-ant:gcp-antispam-spanner-client
Jul 13, 2026
Merged

storage/gcp/antispam: add optional SpannerClient to AntispamOpts#1054
AlCutter merged 1 commit into
transparency-dev:mainfrom
eperrine-ant:gcp-antispam-spanner-client

Conversation

@eperrine-ant

Copy link
Copy Markdown
Contributor

What

Adds an optional SpannerClient field to the GCP antispam AntispamOpts. If set, NewAntispam uses the provided client instead of creating its own, mirroring the existing Config.SpannerClient on the GCP log storage.

Why

Multi-tenant deployments that store several logs' state in one Spanner database (via SpannerTablePrefix, #1040) currently get a separate Spanner client — with its own session pool — for every antispam instance, on top of the log storage's client. Allowing a shared client keeps session usage bounded no matter how many logs share the database.

Notes

  • An injected client must be connected to the database named by the spannerDB parameter. This is validated at construction, since a mismatched client would otherwise silently disable deduplication (lookups treat NotFound as a cache miss).
  • An injected client is never closed by Tessera; its lifecycle stays with the caller.
  • An injected client is also used to apply the initial schema seed mutations. When no client is provided, behavior is unchanged: table preparation uses its own temporary client, and the long-lived client is created after table preparation succeeds.

Testing

  • New shared-client case in TestAntispamStorage drives the full append → follow → dedup-lookup cycle through an injected client against spannertest.
  • New TestAntispamSharedClientWrongDatabase asserts a client connected to a different database is rejected.
  • Existing tests pass unchanged with the field unset.

@eperrine-ant
eperrine-ant marked this pull request as ready for review July 12, 2026 20:37
@eperrine-ant
eperrine-ant requested a review from a team as a code owner July 12, 2026 20:37
@eperrine-ant
eperrine-ant requested a review from phbnf July 12, 2026 20:37
@phbnf
phbnf requested a review from AlCutter July 13, 2026 11:01
@phbnf

phbnf commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR Erin, reassigning to @AlCutter for review.

Allows callers to provide an existing Spanner client to NewAntispam
instead of it always creating its own, mirroring Config.SpannerClient
on the GCP log storage. This lets multi-tenant deployments share a
single client (and its session pool) across the log storage and any
number of antispam instances in the same database.

An injected client must be connected to the database named by the
spannerDB parameter; this is validated at construction since a
mismatched client would otherwise silently disable deduplication
(lookups treat NotFound as a cache miss). An injected client is also
used to apply the initial schema mutations; when no client is
provided, table preparation keeps using its own temporary client and
behavior is unchanged.
@AlCutter
AlCutter force-pushed the gcp-antispam-spanner-client branch from ee4be95 to f920f02 Compare July 13, 2026 11:27
@AlCutter
AlCutter merged commit fb4eb6c into transparency-dev:main Jul 13, 2026
19 of 20 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.

3 participants