Skip to content

Thread the KV EID read through the request and fix the EC TTL decay bug #851

Description

@aram356

Description

From the 2026-07-05 performance & architecture review (P0 finding 5 + KV/EC section).

Blocking KV read gates the hot path. apply_auction_eids_and_device does a synchronous KV get before anything is dispatched (publisher.rs:1350-1362 -> auction/endpoints.rs:309). Every SSAT navigation pays that round trip in TTFB.

Fix: issue the origin fetch async first, then KV + dispatch, then await origin; or carry the entry from the EC context that already read it. Thread the (KvEntry, generation) read once per request through RouteResult into finalize and pull sync — saves 1-2M reads per 1M PV and removes a pre-send RMW read.

EC TTL decay bug (directly undermines the Safari/Firefox CPM bet). The ts-ec cookie lives 1 year, but the KV row expires 1 year after last write, and upsert_partner_ids fails closed on a missing key while nothing recreates the row when the cookie still exists. Long-lived quiet users silently lose their identity graph and all future partner enrichment.

Fix: recreate-on-missing in the upsert path, or a sampled TTL-refresh write (sampling keeps write cost bounded).

Effort / expected effect

  • Effort: Medium
  • Expected effect: -1-2M reads/1M PV; protects the Safari/Firefox CPM bet.

Sequencing item 5 of 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions