Skip to content

bug(api): schema Refresh ignores rows.Err() — a mid-stream error installs a truncated schema #391

Description

@taitelee

Summary

SchemaRegistry.Refresh iterates system.columns rows but never checks rows.Err(), so a transient error partway through the result set swaps in a partial schema as authoritative and logs it as a success.

Detail

internal/discovery/discovery.go:84-108: the for rows.Next() loop ends on error as well as EOF; driver.Rows.Err() (present in clickhouse-go v2.46) is never consulted. A network hiccup / cancellation mid-result yields a truncated tables map that is installed under lock and logged "schema registry refreshed".

Because auto-refresh runs every 60s, a single transient stream error makes tables after the break disappear (ingest/query → 404), truncates the last table's column list (valid rows rejected as "unknown/missing column"; select_all silently drops columns) — until the next successful refresh. Fail-silent where the rest of boot is fail-loud.

Fix direction

Check rows.Err() after the loop and return the error without swapping sr.tables.

Found in a repo-wide audit; verified by code trace.

Activity

  1. added
    bugSomething isn't working
    area/apiHTTP handlers, routing, middleware
    area/ingestIngest pipeline (Bento, batching, DLQ)
    on Jul 8, 2026
  2. coderabbitai commented on Jul 8, 2026

    @coderabbitai
    🔗 Related PRs

    #125 - fix(boot): non-fatal schema discovery, /health 503 with diagnostic [merged]
    #182 - refactor: full api --> ingest --> clickhouse --> dlq refactor [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 Oct 8, 2026

    @EricAndrechek
    Member

    Fixed in #402. Refresh now checks rows.Err() after iterating system.columns and returns the error before the registry is swapped (internal/discovery/discovery.go). A mid-stream driver error therefore keeps the previous schema instead of publishing a truncated one. The system.tables scan added later in #550 has the same check, and TestRefresh_RowsIterationError_Fails in internal/discovery/discovery_test.go covers the case with a simulated network drop.

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/apiHTTP handlers, routing, middlewarearea/ingestIngest pipeline (Bento, batching, DLQ)bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions