cockroachdb / cockroachdb/cockroach
workload: kv workload is hard to apply correctly; read-only workload only ever hits a single row
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
I'll hazard a guess that most folks assume that the reads issued by
`./cockroach workload kv` read data that was either written by previous runs or
by the current run. But unless the workload is set up very carefully, I believe
its point selects almost certainly produce no results.
This is because the PK is not dense - it's basically an int64, randomly chosen.
A random int64 chosen for a read realistically has approximately a zero percent
chance of having been written previously.
To get the semantics most of us would intuit, one needs to first populate a
dataset with a fixed seed, like `--read-percent=0 --seed=1 [...]`, and later
pass the same seed. But this will only read the keys once in the order in which
they were written, and then quickly race off into empty keyspace as well. So one
additionally needs to pass `--cycle-length`.
In a single invocation, `--read-percent=N --cycle-length=10000` should also work
as expected, since the workload will operate on a fixed 10k keys. But this will
also constrain the writes to these keys, i.e. the live dataset won't grow past 10k
keys (though the accumulated MVCC garbage will grow). This isn't ideal either.
I don't think these semantics are what anyone had in mind, so filing this issue
to track what we want to do about it, if anything.
One idea from a slack thread[^1] where this was originally discussed was to add
the bytes read (or number of results read) to the stats output to make it more
obvious what's going on.
Assigning T-testeng as owner since workload/kv is nominally owned by them, but I
assume this will involve a few more cooks.
[^1]: https://cockroachlabs.slack.com/archives/C4X2J0RH6/p1736345016604499
Jira issue: CRDB-46324
Contributor guide
Assessment
This issue has not been assessed yet.