clockworklabs / clockworklabs/SpacetimeDB

Metric `rdb_iter_time` has a bug

Open
#555 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

@joshua-spacetime

See: https://github.com/clockworklabs/SpacetimeDB/blob/f12a238237a926e97ce621c65787050661067c1a/crates/core/src/db/relational_db.rs#L492-L501

I believe that this code executes as follows:

  • A guard is created, starting timing for the db::Iter iterator.
  • An iterator is constructed.
  • The end of the function is reached, so the guard is dropped, ending timing for the iterator.
  • The iterator is returned.
  • The client actually drives the iterator to completion.

To fix this, the guard needs to be embedded in the db::Iter struct itself. This hopefully won't be hairy, the HistogramTimer struct has no lifetimes, is Send, Sync, etc.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with crates/core/src/db/relational_db.rs lines 492-501 and trace how the db::Iter is constructed and returned. Check when HistogramTimer is dropped relative to iteration, then ensure the iterator owns the timer so timing covers client-driven iteration; verify the resulting metric behavior with the repository's relevant checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.