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

engineccl/mvcc: work around time-bound iterator bug #32909

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

danhhz
Copy link
Contributor

@danhhz danhhz commented Dec 6, 2018

For reasons described in #28358, a time-bound iterator will sometimes
see an unresolved intent where there is none. A normal iterator doesn't
have this problem, so we work around it in MVCCIncrementalIterator by
double checking all non-value keys. If the normal iterator has a
different value for the key, it's used instead. If the normal iterator
doesn't have that key, it's skipped.

This fixes both changefeeds and incremental backup.

Closes #32104
Closes #32799

Release note (bug fix): CHANGEFEEDs and incremental BACKUPs no
longer indefinitely hang under an infrequent condition.

@danhhz danhhz requested review from benesch and a team December 6, 2018 18:58
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@danhhz
Copy link
Contributor Author

danhhz commented Dec 6, 2018

@benesch still figuring out how to write tests for this. first wanted to check that this is even fixing it at the right level. thoughts?

@benesch
Copy link
Contributor

benesch commented Dec 6, 2018

Yeah, this looks like the right level! Are you planning to backport this to 2.1?

@danhhz
Copy link
Contributor Author

danhhz commented Dec 6, 2018

Yup!

@benesch
Copy link
Contributor

benesch commented Dec 6, 2018

👍 sounds good. And then we can hopefully rip this out if we come up with a more clever solution within RocksDB.

@danhhz
Copy link
Contributor Author

danhhz commented Dec 11, 2018

Cleaned it up a bit and added some tests. Should be ready to go. Give this one an extra thorough look if you can.

Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

I reviewed this closely, but if you want extra scrutiny perhaps @bdarnell should take a look too?

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/ccl/storageccl/engineccl/mvcc.go, line 54 at r1 (raw file):

	iter engine.Iterator

	// fields used for a workaround for a bug in the time-bound iterator

// ... time-bound iterator (#28358)


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 543 at r1 (raw file):

	// kA -> (intent) [NB this overwrites the intent deletion]
	// kA:3 -> vA3
	// kA _> vA2

Should this be kA:2 -> vA2?


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 554 at r1 (raw file):

	require.NoError(t, engine.MVCCPut(ctx, db, nil, kA, ts2, vA2, nil))
	require.NoError(t, engine.MVCCPut(ctx, db, nil, kA, txnA3.Timestamp, vA3, txnA3))
	require.NoError(t, db.Flush())

❤️ testify


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 593 at r1 (raw file):

	// Sanity check that we see the still unresolved intent for kC ts1.
	_, err = slurpKVs(db, kC, ts0, ts1)
	require.EqualError(t, err, `conflicting intents on "kC"`)

Can you also sanity check that you see the unresolved intent if you slurpKVs(db, kC, ts2, ts3) (i.e., scanning at a higher timestamp than the intent is written)? Just to lock in the behavior until #32421 goes back in.

@danhhz
Copy link
Contributor Author

danhhz commented Dec 11, 2018

Good idea. @bdarnell would you mind taking a look at this as well?

@danhhz danhhz requested a review from bdarnell December 11, 2018 21:39
Copy link
Contributor

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

Copy link
Contributor

@benesch benesch 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


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 593 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

Can you also sanity check that you see the unresolved intent if you slurpKVs(db, kC, ts2, ts3) (i.e., scanning at a higher timestamp than the intent is written)? Just to lock in the behavior until #32421 goes back in.

Never mind. I'm totally mistaken on this point. Ignore this suggesiton.

For reasons described in cockroachdb#28358, a time-bound iterator will sometimes
see an unresolved intent where there is none. A normal iterator doesn't
have this problem, so we work around it in MVCCIncrementalIterator by
double checking all non-value keys. If the normal iterator has a
different value for the key, it's used instead. If the normal iterator
doesn't have that key, it's skipped.

This fixes both changefeeds and incremental backup.

Closes cockroachdb#32104
Closes cockroachdb#32799

Release note (bug fix): `CHANGEFEED`s and incremental `BACKUP`s no
longer indefinitely hang under an infrequent condition.
@danhhz danhhz changed the title [WIP] engineccl/mvcc: work around time-bound iterator bug engineccl/mvcc: work around time-bound iterator bug Dec 13, 2018
Copy link
Contributor Author

@danhhz danhhz left a comment

Choose a reason for hiding this comment

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

Thanks for the reviews!

bors r=bdarnell,benesch

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/ccl/storageccl/engineccl/mvcc.go, line 54 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

// ... time-bound iterator (#28358)

Done.


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 543 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

Should this be kA:2 -> vA2?

Done.


pkg/ccl/storageccl/engineccl/mvcc_test.go, line 554 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

❤️ testify

🙌

craig bot pushed a commit that referenced this pull request Dec 13, 2018
32909: engineccl/mvcc: work around time-bound iterator bug r=bdarnell,benesch a=danhhz

For reasons described in #28358, a time-bound iterator will sometimes
see an unresolved intent where there is none. A normal iterator doesn't
have this problem, so we work around it in MVCCIncrementalIterator by
double checking all non-value keys. If the normal iterator has a
different value for the key, it's used instead. If the normal iterator
doesn't have that key, it's skipped.

This fixes both changefeeds and incremental backup.

Closes #32104
Closes #32799

Release note (bug fix): `CHANGEFEED`s and incremental `BACKUP`s no
longer indefinitely hang under an infrequent condition.

Co-authored-by: Daniel Harrison <[email protected]>
@craig
Copy link
Contributor

craig bot commented Dec 13, 2018

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants