Skip to content

kvserver: support withDiff with TBI in rangefeed catch up scan #69191

Closed
stevendanna wants to merge 1 commit intocockroachdb:masterfrom
stevendanna:tbi-for-catchup-scan-with-diff
Closed

kvserver: support withDiff with TBI in rangefeed catch up scan #69191
stevendanna wants to merge 1 commit intocockroachdb:masterfrom
stevendanna:tbi-for-catchup-scan-with-diff

Conversation

@stevendanna
Copy link
Copy Markdown
Collaborator

Build on #66312

The MVCCIncrementalIterator previously could not be used in catchup
scan when the withDiff option was provided because the time-based
filtering resulted in some previous values of a given key being
skipped.

To account for this, we use the non-timebound iterator inside the
MVCCIncrementalIterator to return the previous value of a given
key (previous from the perspective of the timestamp, not the iterator)
any time the time optimization would have skipped it by moving to a
new key.

I could not think of a good name for this rather odd function;
suggestions are welcome.

Release Notes: None

@stevendanna stevendanna requested review from a team as code owners August 20, 2021 10:42
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@stevendanna stevendanna force-pushed the tbi-for-catchup-scan-with-diff branch 2 times, most recently from 95f99a4 to 0a7621d Compare August 20, 2021 12:09
@stevendanna stevendanna changed the title kvserver: support withDiff in CatchupScan kvserver: support withDiff with TBI in CatchupScan Aug 20, 2021

var valueBuf []byte

reorderBuf := make([]roachpb.RangeFeedEvent, 0, 5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's some magic constant action.

@stevendanna stevendanna force-pushed the tbi-for-catchup-scan-with-diff branch from 0a7621d to 48da0c1 Compare August 20, 2021 16:57
@stevendanna stevendanna force-pushed the tbi-for-catchup-scan-with-diff branch from 48da0c1 to ab635a6 Compare September 1, 2021 16:45
@stevendanna stevendanna changed the title kvserver: support withDiff with TBI in CatchupScan kvserver: support withDiff with TBI in rangefeed catch up scan Sep 1, 2021
@stevendanna
Copy link
Copy Markdown
Collaborator Author

cc @sumeerbhola You mentioned being willing to take a look at a hacky implementation of the withDiff support. I've put a release justification on here to appease the linter, don't feel pressured to take a look at this before the branch cut if you don't have time.

The MVCCIncrementalIterator previously could not be used in catch up
scan when the withDiff option was provided because the time-based
filtering resulted in some previous values of a given key being
skipped.

To account for this, we use the non-timebound iterator inside the
MVCCIncrementalIterator to return the previous value of a given
key (previous from the perspective of the timestamp, not the iterator)
any time the time optimization would have skipped it by moving to a
new key.

I could not think of a good name for this rather odd function;
suggestions are welcome.

Release note: None

Release justification: Expands scope of catch up scan performance
improvements to address recent high priority escalations.
@stevendanna stevendanna force-pushed the tbi-for-catchup-scan-with-diff branch from ab635a6 to c23b038 Compare September 3, 2021 11:24
@sumeerbhola
Copy link
Copy Markdown
Collaborator

cc @sumeerbhola You mentioned being willing to take a look at a hacky implementation of the withDiff support. I've put a release justification on here to appease the linter, don't feel pressured to take a look at this before the branch cut if you don't have time.

Last week was affected by release blockers and that will continue this week (+ breather week). So I am unlikely to get to it this week.

@tbg tbg removed the request for review from a team September 15, 2021 08:20
Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola 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 (waiting on @miretskiy, @stevendanna, and @sumeerbhola)


pkg/storage/mvcc_incremental_iterator.go, line 269 at r4 (raw file):

//
// This is used by rangefeed catchup scans.
func (i *MVCCIncrementalIterator) NextSavingSkipped(key roachpb.Key) bool {

This looks like a clean enough change and avoids an additional iterator, which is good.

However, given that this is for 22.1, I'd prefer to wait until we're rewritten MVCCIncrementalIterator to no longer contain iter. The rewritten one would only contain the timeBoundIter and a lock table iter, since we no longer have interleaved intents. I think we'd need to wrap that MVCCIncrementalIterator and a regular MVCCIterator (with MVCCKeyIterKind) to produce this diff behavior, so it would be different from what is done in this PR.

Actually if you want to write this wrapping-with-diff iterator now, it is probably ok to proceed with it. Hmm, I think you will run into trouble due to the iterator caching behavior in pebbleBatch and pebbleReadOnly. The MVCCIncrementalIterator.iter uses up both the cache "slots" so the code will panic when constructing the regular iterator for the wrapper, since it needs another pebbleReadOnly.normalIter. Once the rewrite is done, this will not be a problem since the MVCCIncrementalIterator will no longer use the pebbleReadOnly.normalIter "slot".

@stevendanna
Copy link
Copy Markdown
Collaborator Author

However, given that this is for 22.1, I'd prefer to wait until we're rewritten MVCCIncrementalIterator to no longer contain iter. The rewritten one would only contain the timeBoundIter and a lock table iter, since we no longer have interleaved intents. I think we'd need to wrap that MVCCIncrementalIterator and a regular MVCCIterator (with MVCCKeyIterKind) to produce this diff behavior, so it would be different from what is done in this PR.

Thanks for taking a look. This sounds like a good plan to me. Also, the Changefeed Nemeses tests revealed a problem with this PR that I haven't been able to look into yet, so this isn't merge-able as is.

@stevendanna stevendanna added the do-not-merge bors won't merge a PR with this label. label Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge bors won't merge a PR with this label.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants