Skip to content

(HACKATHON) sql: inject retry errors with test session var#45224

Open
knz wants to merge 1 commit intocockroachdb:masterfrom
knz:20200219-force-retry
Open

(HACKATHON) sql: inject retry errors with test session var#45224
knz wants to merge 1 commit intocockroachdb:masterfrom
knz:20200219-force-retry

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Feb 19, 2020

Written with @johnrk

Previously, retry errors were only produced under contention.

This not good for training developers; because in developer
environments there is often no natural contention. It's thus possible
for a dev to move very far forward with their app without realizing
they need to care about retry errors.

This patch makes it possible for devs to validate that they have all
the necessary retry loops. Client side retry errors are forced; after
3 valid retry iterations (with the cockroach_restart savepoint
rollback) the transaction is allowed to succeed. This mechanism is
only enabled when the (new) session var retry_errors_enabled is set
to true—and it defaults to false.

At this point this feature is restricted to explicit transactions.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz knz force-pushed the 20200219-force-retry branch from 2ec131e to 1dec239 Compare February 20, 2020 03:53
Previously, retry errors were only produced under contention.

This not good for training developers; because in developer
environments there is often no natural contention. It's thus possible
for a dev to move very far forward with their app without realizing
they need to care about retry errors.

This patch makes it possible for devs to validate that they have all
the necessary retry loops. Client side retry errors are forced; after
3 valid retry iterations (with the `cockroach_restart` savepoint
rollback) the transaction is allowed to succeed. This mechanism is
only enabled when the (new) session var `retry_errors_enabled` is set
to true—and it defaults to false.

At this point this feature is restricted to explicit transactions.

Release note: None
@knz knz force-pushed the 20200219-force-retry branch from 1dec239 to 6864aaf Compare February 20, 2020 04:24
Copy link
Copy Markdown
Contributor

@dt dt left a comment

Choose a reason for hiding this comment

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

This is super cool! I just had two nits about naming/messaging.


// CockroachDB extension.
`retry_errors_enabled`: {
GetStringVal: makeBoolGetStringValFn(`retry_errors_enabled`),
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.

bikeshed/nitpick: 2¢ i'd give this a name like inject_retry_errors that makes it clearer that this controls synthetic/injected errors (i.e. as is, i think you could read this setting as automatically retrying on errors).

if ex.sessionData.RetryErrorsEnabled && stmt.AST.StatementTag() != "SET" {
if planner.Txn().Epoch() < ex.state.lastEpoch+3 {
retryErr := planner.Txn().GenerateForcedRetryableError(
ctx, "forced by executor")
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.

nit: I'd say "injected" by executor since it you might not be sure why it was "forced by executor". In. fact, i'd include the name of the flag in the error too, e.g. "error injected by executor due to <setting_name>".

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Feb 20, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

X-noremind Bots won't notify about PRs with X-noremind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants