Skip to content

bug(query): admin mutations via /v1/admin/query don't invalidate the structured-query cache — stale reads for up to an hour #394

Open

Description

@taitelee

Summary

Only the ingest worker ever calls Cache.Invalidate. Admin mutations (DELETE/UPDATE/TRUNCATE/ALTER via /v1/admin/query — the sanctioned mutation path) bump nothing, so /v1/query keeps serving pre-mutation cached rows until TTL expiry.

Detail

  • internal/ingest/worker.go:488 is the sole Cache.Invalidate caller in the tree.
  • internal/api/query.go (admin raw-SQL proxy) holds no cache reference.
  • QueryTimeToTTL allows up to 1h (floor 10s).

Scenario: admin performs a GDPR erasure DELETE FROM users WHERE id = ... via POST /v1/admin/query; POST /v1/query continues returning the deleted rows from LocalCache for up to an hour, with no operator recourse short of restart.

Fix direction

Give the admin-query handler a cache handle and invalidate the affected table(s) after a successful mutation (best-effort table extraction, mirroring the ingest path), or bypass/short-TTL the cache for tables recently mutated.

Found in a repo-wide audit; verified by code trace. Distinct from #382 (ingest-path version race) and #362 (MV writes vs SSE — same "only ingest drives the reactive layer" root cause, different surface).

Activity

  1. added
    bugSomething isn't working
    area/queryStructured query AST, SQL builder
    area/cacheLocal / shared / tiered caching
    on Jul 8, 2026
  2. coderabbitai commented on Jul 8, 2026

    @coderabbitai
    🔗 Related PRs

    #164 - refactor(ingest)!: insert-only pipeline; mutations via /v1/query [closed]
    #177 - feat: caching for local table/scope invalidation [closed]
    #182 - refactor: full api --> ingest --> clickhouse --> dlq refactor [closed]
    #314 - feat(cache): namespace-versioned cache keys for queries and pipes [closed]


    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. EricAndrechek commented on Sep 25, 2026

    @EricAndrechek
    Member

    @/tmp/pr_edits/comment5829323965.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cacheLocal / shared / tiered cachingarea/queryStructured query AST, SQL builderbugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions