Skip to content

kvcoord: include replica info in RangeIterator.Seek into trace#92947

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:range-iterator
Dec 6, 2022
Merged

kvcoord: include replica info in RangeIterator.Seek into trace#92947
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:range-iterator

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich commented Dec 2, 2022

This commit modifies the existing "info" log message into an "event"
when seeking the range iterator. This makes it so that the result of the
seek (the replica information) is included into the trace. Additionally,
this commit includes the corresponding message to be included into the
KV trace. The original "info" log message was added about five years ago
and probably hasn't been that useful.

Here is an example of the trace event:

key: /NamespaceTable/30/1/100/101/"t"/4/1, desc: r32:/NamespaceTable/{30-Max} [(n1,s1):1, next=2, gen=0]

Informs: https://github.com/cockroachlabs/support/issues/1933.

Release note: None

@yuzefovich yuzefovich requested a review from AlexTalks December 2, 2022 19:35
@yuzefovich yuzefovich requested a review from a team as a code owner December 2, 2022 19:35
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @AlexTalks)

@yuzefovich
Copy link
Copy Markdown
Member Author

TFTR!

bors r+

Copy link
Copy Markdown
Contributor

@AlexTalks AlexTalks left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/kv/kvclient/kvcoord/range_iter.go line 183 at r1 (raw file):

func (ri *RangeIterator) Seek(ctx context.Context, key roachpb.RKey, scanDir ScanDirection) {
	if log.HasSpanOrEvent(ctx) {
		defer func() {

Question though: why defer this? once we get to ri.ds.getRoutingInfo(..) we are looking up (in a retry loop) the range info in the range cache, which may involve a KV lookup of meta1/meta2 - i.e. a potentially slow RPC. I I assume it's because you want to incorporate the range info, but wouldn't it be better to potentially do log.Eventf(..) both here and after the lookup?

@yuzefovich
Copy link
Copy Markdown
Member Author

Let me think about that.

bors r-

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 3, 2022

Canceled.

@yuzefovich yuzefovich changed the title kvcoord: include replica info in RangeIterator.Seek kvcoord: include replica info in RangeIterator.Seek into trace Dec 3, 2022
Copy link
Copy Markdown
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @AlexTalks and @arulajmani)


pkg/kv/kvclient/kvcoord/range_iter.go line 183 at r1 (raw file):

Previously, AlexTalks (Alex Sarkesian) wrote…

Question though: why defer this? once we get to ri.ds.getRoutingInfo(..) we are looking up (in a retry loop) the range info in the range cache, which may involve a KV lookup of meta1/meta2 - i.e. a potentially slow RPC. I I assume it's because you want to incorporate the range info, but wouldn't it be better to potentially do log.Eventf(..) both here and after the lookup?

I didn't want to pollute the trace too much, but you raise a good point that we might be interested to know how long this Seek actually takes. Thus, I changed the code to replace the existing "info" log message into a trace event. That "info" message was introduced in #15413, and probably hasn't been very useful, but please let me know if you think otherwise.

Copy link
Copy Markdown
Contributor

@AlexTalks AlexTalks left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @arulajmani)

This commit modifies the existing "info" log message into an "event"
when seeking the range iterator. This makes it so that the result of the
seek (the replica information) is included into the trace. Additionally,
this commit includes the corresponding message to be included into the
KV trace. The original "info" log message was added about five years ago
and probably hasn't been that useful.

Here is an example of the trace event:
```
key: /NamespaceTable/30/1/100/101/"t"/4/1, desc: r32:/NamespaceTable/{30-Max} [(n1,s1):1, next=2, gen=0]
```

Release note: None
@yuzefovich
Copy link
Copy Markdown
Member Author

Needed to adjust one logic test file.

TFTRs!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 6, 2022

Build succeeded:

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Dec 6, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from c1ae40b to blathers/backport-release-22.1-92947: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

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.

4 participants