Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvserver: add raft.replication.latency #106094

Merged
merged 5 commits into from
Jul 5, 2023

Conversation

tbg
Copy link
Member

@tbg tbg commented Jul 4, 2023

The help text says it all:


The duration elapsed between having evaluated a BatchRequest and it being
reflected in the proposer's state machine (i.e. having applied fully).

This encompasses time spent in the quota pool, in replication (including
reproposals), and application, but notably not sequencing latency (i.e.
contention and latch acquisition).

No measurement is recorded for read-only commands as well as read-write commands
which end up not writing (such as a DeleteRange on an empty span). Commands that
result in 'above-replication' errors (i.e. txn retries, etc) are similarly
excluded. Errors that arise while waiting for the in-flight replication result
or result from application of the command are included.

Note also that usually, clients are signalled at beginning of application, but
the recorded measurement captures the entirety of log application.

Commands that use async consensus will still cause a measurement that reflects
the actual replication latency, despite returning early to the client.


Fixes #83262.

Epic: CRDB-25287
Release note (ops change): a histogram metric raft.replication.latency was added.
It tracks the time between evaluation and application of the command. This includes
time spent in the quota pool, in replication (including reproposals) as well as log
application, but notably not sequencing latency, i.e. contention and latch
acquisition.

@blathers-crl
Copy link

blathers-crl bot commented Jul 4, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@tbg tbg force-pushed the replication-latency branch from 86ac03c to eaca25f Compare July 4, 2023 07:40
@tbg tbg marked this pull request as ready for review July 4, 2023 07:56
@tbg tbg requested a review from a team July 4, 2023 07:56
@tbg tbg requested a review from a team as a code owner July 4, 2023 07:56
@erikgrinaker erikgrinaker self-requested a review July 5, 2023 09:25
Copy link
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

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

Amazing to finally land this!

tbg added 5 commits July 5, 2023 12:55
Distinguish the unreplicated from the replicated case, since we want metrics
for the replicated one and to that end will need to construct a different
endCmds in a follow-up commit.
We're not actually measuring replication latency yet, but this
will happen in the next commit.
The help text says it all:

----

The duration elapsed between having evaluated a BatchRequest and it being
reflected in the proposer's state machine (i.e. having applied fully).

This encompasses time spent in the quota pool, in replication (including
reproposals), and application, but notably *not* sequencing latency (i.e.
contention and latch acquisition).

No measurement is recorded for read-only commands as well as read-write commands
which end up not writing (such as a DeleteRange on an empty span). Commands that
result in 'above-replication' errors (i.e. txn retries, etc) are similarly
excluded. Errors that arise while waiting for the in-flight replication result
or result from application of the command are included.

Note also that usually, clients are signalled at beginning of application, but
the recorded measurement captures the entirety of log application.

Commands that use async consensus will still cause a measurement that reflects
the actual replication latency, despite returning early to the client.

----

Fixes cockroachdb#83262.

Epic: CRDB-25287
Release note (ops change): a histogram metric raft.replication.latency was added.
It tracks the time between evaluation and application of the command. This includes
time spent in the quota pool, in replication (including reproposals) as well as log
application, but notably *not* sequencing latency, i.e. contention and latch
acquisition.
@tbg tbg force-pushed the replication-latency branch from eaca25f to 77315a0 Compare July 5, 2023 11:17
@tbg
Copy link
Member Author

tbg commented Jul 5, 2023

bors r=erikgrinaker

@craig
Copy link
Contributor

craig bot commented Jul 5, 2023

Build succeeded:

@craig craig bot merged commit 4456a30 into cockroachdb:master Jul 5, 2023
craig bot pushed a commit that referenced this pull request Jul 11, 2023
106095: kvserver: misc replication-related cleanups r=erikgrinaker a=tbg

These are a few cleanups done as part of #106094 which aren't in that PR's main
workstream.

Epic: CRDB-25287
Release note: None


Co-authored-by: Tobias Grieger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kvserver: replication latency metrics
3 participants