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: bump the in-memory GC threshold as a pre-apply side effect #83197

Merged
merged 1 commit into from
Jul 1, 2022

Conversation

aayushshah15
Copy link
Contributor

This commit changes where the in-memory GC threshold on a Replica is
bumped during the application of a GC request.

Previously, the in-memory GC threshold was bumped as a post-apply side
effect. Additionally, GC requests do not acquire latches at the
timestamp that they are garbage collecting, and thus, readers need to
take additional care to ensure that results aren't served off of a
partial state.

Readers today rely on the invariant that the in-memory GC threshold is
bumped before the actual garbage collection. This today is true because
the mvccGCQueue issues GC requests in 2 phases: the first that simply
bumps the in-memory GC threshold, and the second one that performs the
actual garbage collection. If the in-memory GC threshold were bumped in
the pre-apply phase of command application, this usage quirk wouldn't
need to exist. That's what this commit does.

Relates to #55293

Release note: None

@aayushshah15 aayushshah15 requested a review from a team as a code owner June 22, 2022 17:00
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@nvanbenschoten nvanbenschoten 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 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aayushshah15 and @arulajmani)


pkg/kv/kvserver/replica_application_state_machine.go line 756 at r3 (raw file):

	}

	if res.State != nil && res.State.GCThreshold != nil {

Could we add a comment here explaining why this is a pre-apply trigger? Something similar to what you have in the commit message would be great.


pkg/kv/kvserver/replica_test.go line 8652 at r3 (raw file):

	testutils.RunTrueAndFalse(t, "followerRead", func(t *testing.T, followerRead bool) {
		testutils.RunTrueAndFalse(t, "thresholdFirst", func(t *testing.T, thresholdFirst bool) {

[tiny nit] is this now a stray line?

@aayushshah15 aayushshah15 force-pushed the bumpGCThreshPreApply branch 2 times, most recently from ce4a73d to c56926c Compare June 30, 2022 22:54
This commit changes where the in-memory GC threshold on a Replica is
bumped during the application of a GC request.

Previously, the in-memory GC threshold was bumped as a post-apply side
effect. Additionally, GC requests do not acquire latches at the
timestamp that they are garbage collecting, and thus, readers need to
take additional care to ensure that results aren't served off of a
partial state.

Readers today rely on the invariant that the in-memory GC threshold is
bumped before the actual garbage collection. This today is true because
the mvccGCQueue issues GC requests in 2 phases: the first that simply
bumps the in-memory GC threshold, and the second one that performs the
actual garbage collection. If the in-memory GC threshold were bumped in
the pre-apply phase of command application, this usage quirk wouldn't
need to exist. That's what this commit does.

Relates to cockroachdb#55293

Release note: None
@aayushshah15 aayushshah15 force-pushed the bumpGCThreshPreApply branch from c56926c to f18f31e Compare June 30, 2022 22:55
Copy link
Contributor Author

@aayushshah15 aayushshah15 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 review!

bors r+

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


pkg/kv/kvserver/replica_application_state_machine.go line 756 at r3 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Could we add a comment here explaining why this is a pre-apply trigger? Something similar to what you have in the commit message would be great.

Done.

@craig
Copy link
Contributor

craig bot commented Jul 1, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jul 1, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jul 1, 2022

Build failed:

@aayushshah15
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 1, 2022

Build succeeded:

@craig craig bot merged commit 66f6952 into cockroachdb:master Jul 1, 2022
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.

3 participants