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

kv: clean up randomized retryable error injection #108828

Conversation

nvanbenschoten
Copy link
Member

This commit includes a collection of kv-level cleanups for the randomized retryable error injection functionality recently introduced in #107954. Notably, it:

  • removes the dependency from kvcoord.TxnCoordSender on kv.Txn by adjusting the parameter of ClientTestingKnobs.TransactionRetryFilter.
  • unexports kv.Txn.DebugNameLocked
  • deletes COCKROACH_DISABLE_COMMIT_SANITY_CHECK again, which was unused
  • removes rng sources in favor of the global rand, for simplicity
  • cleans up and adds some comments

Epic: None
Release note: None

@nvanbenschoten nvanbenschoten requested a review from ecwall August 16, 2023 04:49
@nvanbenschoten nvanbenschoten requested review from a team as code owners August 16, 2023 04:49
@nvanbenschoten nvanbenschoten requested review from rhu713 and removed request for a team August 16, 2023 04:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/cleanupTestingShouldRetry branch from 6a7e698 to 2e79ed8 Compare August 16, 2023 17:00
Copy link
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 10 of 10 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ecwall, @nvanbenschoten, and @rhu713)


pkg/kv/sender.go line 348 at r1 (raw file):

	// TestingShouldRetry returns true if transaction retry errors should be
	// randomly returned to callers. Note, it is the responsibility of

While you're here, s/Note,/Note/g


pkg/kv/kvclient/kvcoord/txn_coord_sender.go line 44 at r1 (raw file):

//
// See: https://github.com/cockroachdb/cockroach/pull/73512.
var DisableCommitSanityCheck = envutil.EnvOrDefaultBool("COCKROACH_DISABLE_COMMIT_SANITY_CHECK", false)

Hopefully this is the last time we see this env var 🥲


pkg/kv/kvclient/kvcoord/txn_coord_sender.go line 1541 at r1 (raw file):

}

// TestingShouldRetry is part of the TxnSender interface.

Shouldn't this have been caught by some linter? Do you know if something has changed recently?


pkg/kv/kvclient/kvcoord/txn_coord_sender.go line 1548 at r1 (raw file):

		return false
	}
	if filter := tc.testingKnobs.TransactionRetryFilter; filter != nil && filter(tc.mu.txn.Clone()) {

nit: is it worth saying we're cloning the transaction here because we don't want the filter to modify the transaction? Or, better yet, should the testing knob be accepting the transaction by value instead to make the contract here clearer?

This commit includes a collection of kv-level cleanups for the
randomized retryable error injection functionality recently introduced
in cockroachdb#107954. Notably, it:
- removes the dependency from `kvcoord.TxnCoordSender` on `kv.Txn` by adjusting
  the parameter of `ClientTestingKnobs.TransactionRetryFilter`.
- unexports `kv.Txn.DebugNameLocked`
- deletes `COCKROACH_DISABLE_COMMIT_SANITY_CHECK` again, which was unused
- removes rng sources in favor of the global rand, for simplicity
- cleans up and adds some comments

Epic: None
Release note: None
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/cleanupTestingShouldRetry branch from 2e79ed8 to 6ba29d6 Compare August 20, 2023 18:11
Copy link
Member Author

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

TFTR!

bors r+

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


pkg/kv/sender.go line 348 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

While you're here, s/Note,/Note/g

Done.


pkg/kv/kvclient/kvcoord/txn_coord_sender.go line 1541 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Shouldn't this have been caught by some linter? Do you know if something has changed recently?

I was also surprised. I'm not aware of any changes but have noticed that I seem to get bugged about this less often these days, so I think something probably has changed.


pkg/kv/kvclient/kvcoord/txn_coord_sender.go line 1548 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

nit: is it worth saying we're cloning the transaction here because we don't want the filter to modify the transaction? Or, better yet, should the testing knob be accepting the transaction by value instead to make the contract here clearer?

Good idea. Went with the pass-by-value suggestion.

@craig
Copy link
Contributor

craig bot commented Aug 20, 2023

Build succeeded:

@craig craig bot merged commit a475a51 into cockroachdb:master Aug 20, 2023
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/cleanupTestingShouldRetry branch August 20, 2023 23:27
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