Skip to content

vector-store: add CDC reader health metrics#515

Merged
ewienik merged 6 commits into
scylladb:masterfrom
QuerthDP:enhance-metrics-simple
Jul 14, 2026
Merged

vector-store: add CDC reader health metrics#515
ewienik merged 6 commits into
scylladb:masterfrom
QuerthDP:enhance-metrics-simple

Conversation

@QuerthDP

@QuerthDP QuerthDP commented Jul 10, 2026

Copy link
Copy Markdown
Member

Adds Prometheus metrics for CDC reader health, as a follow-up to a recent
incident where a CDC reader silently stopped processing changes without
any visible signal.

  • cdc_reader_up - whether each index's CDC reader (wide/fine) is currently running or stopped.
  • cdc_handler_errors_total - CDC handler errors per index and reader.
  • cdc_reader_restarts_total - restart-after-backoff attempts per index and reader.

Also fixes two issues found while testing this work:

  • a pre-existing race in the CDC handler shutdown path that could orphan the driver's per-stream fetch tasks indefinitely instead of stopping them.
  • a pre-existing leak of indexing_lag_seconds series on index deletion.

Split from: #503 as it kept getting bigger.
This patch will introduce the straightforward metrics that could be supported out of the box.
The latter will include the cdc_last_processed_timestamp_seconds metric and a potential refactor of db_cdc.rs.

Refs: VECTOR-722
Fixes: VECTOR-739

@QuerthDP
QuerthDP force-pushed the enhance-metrics-simple branch 10 times, most recently from f711492 to cae49ac Compare July 13, 2026 10:33
@QuerthDP
QuerthDP requested a review from Copilot July 13, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Prometheus metrics to surface CDC reader health per index (wide/fine), addressing cases where a CDC reader stops processing without an obvious signal.

Changes:

  • Add three new exported metrics: cdc_reader_up, cdc_handler_errors_total, and cdc_reader_restarts_total, including unit tests for export and label cleanup behavior.
  • Wire Arc<Metrics> through DB/index creation into the CDC actor so CDC readers can update these metrics and clean up their series on shutdown.
  • Update call sites and test match arms to accommodate the new metrics field in Db::GetDbIndex.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/vector-store/tests/integration/db_basic.rs Updates Db::GetDbIndex pattern matching to ignore the newly added message field.
crates/vector-store/src/metrics.rs Defines/registers new CDC health metrics and adds tests for export/removal semantics.
crates/vector-store/src/engine.rs Passes metrics into get_db_index during index creation.
crates/vector-store/src/db.rs Extends Db::GetDbIndex / DbExt::get_db_index to carry Arc<Metrics> through to index creation.
crates/vector-store/src/db_index.rs Threads metrics into CDC actor creation for each index’s readers.
crates/vector-store/src/db_cdc.rs Implements CDC reader metric reporting (up, handler errors, restarts) and adds targeted tests.

Comment thread crates/vector-store/src/db_cdc.rs Outdated
@QuerthDP
QuerthDP force-pushed the enhance-metrics-simple branch from cae49ac to 78d4fce Compare July 13, 2026 11:03
@QuerthDP
QuerthDP marked this pull request as ready for review July 13, 2026 11:07
@QuerthDP
QuerthDP requested a review from ewienik July 13, 2026 11:07
Comment thread crates/vector-store/src/db_cdc.rs Outdated
Comment thread crates/vector-store/src/db.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
`remove_index_labels` cleared `latency`/`size`/`modified`
for a deleted index, but left `indexing_lag_seconds` behind,
leaking a high-cardinality series per index over its lifetime.
@QuerthDP
QuerthDP force-pushed the enhance-metrics-simple branch from 78d4fce to 578d5a2 Compare July 14, 2026 07:03
@QuerthDP

Copy link
Copy Markdown
Member Author

Changelog:

@QuerthDP

Copy link
Copy Markdown
Member Author

Changelog:

Comment thread crates/vector-store/src/lib.rs Outdated
Comment thread crates/vector-store/tests/integration/db_basic.rs Outdated
Comment thread crates/vector-store/src/db.rs Outdated
Comment thread crates/vector-store/src/db_cdc.rs Outdated
QuerthDP added 2 commits July 14, 2026 14:21
Passes the shared metrics registry down through the index-creation
call path so CDC reader metrics can be recorded on it, rather than
constructing or looking one up separately inside the CDC actor.
Give the wide/fine reader labels names (READER_WIDE, READER_FINE)
instead of inline string literals, so every CDC metric can share
the same label values.
QuerthDP added 3 commits July 14, 2026 14:21
Reports whether each index's CDC reader (wide/fine) is currently
running or stopped, so an incident like a silently dead reader is
directly observable.

This is the first CDC-reader-scoped metric, so it also introduces a
separate cleanup path for CDC reader labels. A reader's actor keeps
running asynchronously for a while after its index is deleted, so
removing its labels immediately would race with in-flight updates and
just recreate the series. Each reader instead removes its own labels
once it has fully, finally stopped.
Counts CDC handler errors per index and reader, alongside the
existing internal `cdc-handler-errors` counter.
Counts restart after backoff attempts per index and reader,
to distinguish a reader that recovers on its own from one stuck
restarting.
@QuerthDP
QuerthDP force-pushed the enhance-metrics-simple branch from b7379dd to 1e7a3ad Compare July 14, 2026 12:22
@QuerthDP

Copy link
Copy Markdown
Member Author

Changelog:

  • remove run_with_metrics, instead add Metrics as an argument to run
  • remove leftovers
  • use KeyspaceName and IndexName in record_* functions

@QuerthDP
QuerthDP requested a review from ewienik July 14, 2026 12:24
@ewienik
ewienik added this pull request to the merge queue Jul 14, 2026
Merged via the queue into scylladb:master with commit 17f9003 Jul 14, 2026
41 checks passed
ewienik added a commit to ewienik/vector-store that referenced this pull request Jul 14, 2026
…tamp metric (scylladb#503)

Adds last Prometheus metric for CDC reader health (after
scylladb#515), as a follow-up to a
recent incident where a CDC reader silently stopped processing changes
without any visible signal.

The added metric is `cdc_last_processed_timestamp_seconds` - a
cause-agnostic lag indicator showing how far each CDC reader has
consumed its log window (minimum across all tracked streams), reported
through a `CDCCheckpointSaver` so it keeps advancing even when the table
receives no writes. Resets on generation transitions.

Also splits `db_cdc` into its own module, since the actor loop and the
CDC consumer were two fairly independent responsibilities sharing one
large file, and this metric needed its own submodule for the
`checkpoint-saver` wiring.

Fixes: VECTOR-722
@QuerthDP
QuerthDP deleted the enhance-metrics-simple branch July 16, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants