Skip to content

vector-store: use CDCCheckpointSaver to expose last processed timestamp metric#503

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

vector-store: use CDCCheckpointSaver to expose last processed timestamp metric#503
ewienik merged 2 commits into
scylladb:masterfrom
QuerthDP:enhance-cdc-metrics

Conversation

@QuerthDP

@QuerthDP QuerthDP commented Jul 6, 2026

Copy link
Copy Markdown
Member

Adds last Prometheus metric for CDC reader health (after #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 force-pushed the enhance-cdc-metrics branch from ec7ec71 to f3d727a Compare July 9, 2026 10:02
@QuerthDP QuerthDP changed the title vector-store: enhance CDC metrics vector-store: add CDC reader health metrics Jul 9, 2026
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch 4 times, most recently from cc47e5b to 5ad6647 Compare July 9, 2026 10:40
@QuerthDP
QuerthDP requested a review from Copilot July 9, 2026 11:01

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

Adds Prometheus instrumentation to make CDC reader health and progress observable per index/reader, addressing cases where CDC processing can stall silently.

Changes:

  • Introduces CDC reader health/progress metrics (cdc_reader_up, handler errors, restarts, and consumed-window checkpoint timestamp) and registers them with the existing Prometheus registry.
  • Plumbs Metrics into DB index creation so CDC actors can report per-index/per-reader series.
  • Adds unit tests validating metric export and label cleanup behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/vector-store/tests/integration/db_basic.rs Updates test harness pattern matching for the extended Db::GetDbIndex message.
crates/vector-store/src/metrics.rs Adds/registers new CDC metrics and extends label cleanup; adds export/cleanup tests.
crates/vector-store/src/engine.rs Passes metrics into get_db_index so DB/CDC layers can emit per-index metrics.
crates/vector-store/src/db.rs Extends Db::GetDbIndex/DbExt::get_db_index to carry Arc<Metrics> through the DB actor.
crates/vector-store/src/db_index.rs Threads Arc<Metrics> into CDC actor construction (wide/fine).
crates/vector-store/src/db_cdc.rs Implements CDC reader metrics (up/down, restarts, handler errors) and a checkpoint-saver that reports consumed-window progress.

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/metrics.rs
QuerthDP added a commit to QuerthDP/vector-store that referenced this pull request Jul 9, 2026
remove_index_labels cleared latency/size/modified and the CDC
metrics for a deleted index, but left indexing_lag_seconds behind,
leaking a high-cardinality series per index over its lifetime.

Reported by Copilot on PR scylladb#503.
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch from 5ad6647 to f4d4255 Compare July 9, 2026 11:48
QuerthDP added a commit to QuerthDP/vector-store that referenced this pull request Jul 9, 2026
remove_index_labels cleared latency/size/modified and the CDC
metrics for a deleted index, but left indexing_lag_seconds behind,
leaking a high-cardinality series per index over its lifetime.

Reported by Copilot on PR scylladb#503.
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch 8 times, most recently from a397908 to eb985a8 Compare July 10, 2026 08:55
@QuerthDP QuerthDP changed the title vector-store: add CDC reader health metrics vector-store: use CDCCheckpointSaver to expose last processed timestamp metric Jul 10, 2026
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch 5 times, most recently from ce1b75c to 3dd49aa Compare July 14, 2026 07:53
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch 2 times, most recently from d7a9286 to 83f3caf Compare July 14, 2026 09:03
@QuerthDP
QuerthDP requested a review from Copilot July 14, 2026 09:03

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comment thread crates/vector-store/src/db_cdc/consumer.rs Outdated
Comment thread crates/vector-store/src/db_cdc/checkpoint_saver.rs
Comment thread crates/vector-store/src/db_cdc/checkpoint_saver.rs
Comment thread crates/vector-store/src/metrics.rs Outdated
Comment thread crates/vector-store/src/lib.rs Outdated
@QuerthDP
QuerthDP requested a review from ewienik July 14, 2026 09:11
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch from 83f3caf to 217814e Compare July 14, 2026 09:29
@QuerthDP

Copy link
Copy Markdown
Member Author

Changelog:

  • fix existing typo

This PR is ready for review. Waiting for #515 to get in to rebase on that and open.

ewienik added a commit to ewienik/vector-store that referenced this pull request Jul 14, 2026
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: scylladb#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 added 2 commits July 14, 2026 15:59
The actor loop and the CDC consumer are two fairly independent
responsibilities that happened to share one large file.
Splitting them into their own submodules keeps each one focused
and makes room for adding more CDC-related code without the file
growing without bound.
Cause-agnostic lag indicator: how far the CDC reader has consumed its
log window (minimum across all tracked streams), reported through a
`CDCCheckpointSaver` so it keeps advancing even without table writes.
Resets on generation transitions.
@QuerthDP
QuerthDP force-pushed the enhance-cdc-metrics branch from 217814e to be20161 Compare July 14, 2026 14:04
@QuerthDP
QuerthDP marked this pull request as ready for review July 14, 2026 14:05
@ewienik
ewienik added this pull request to the merge queue Jul 14, 2026
Merged via the queue into scylladb:master with commit a2e9951 Jul 14, 2026
41 checks passed
@QuerthDP
QuerthDP deleted the enhance-cdc-metrics branch July 16, 2026 07:45
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