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

sql,metrics: do not increment ROLLBACK counter if in CommitWait #59781

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Feb 3, 2021

fixes #50780

Release note (bug fix): Previously if RELEASE SAVEPOINT cockroach_restart
was followed by ROLLBACK, the sql.txn.rollback.count
metric would be incremented. This was incorrect, since the txn had already
committed. Now that metric is not incremented in this case.

@rafiss rafiss requested a review from nvanbenschoten February 3, 2021 22:27
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss
Copy link
Collaborator Author

rafiss commented Feb 3, 2021

Are there tests for this anywhere?

@rafiss rafiss requested a review from a team February 4, 2021 02:53
@otan
Copy link
Contributor

otan commented Feb 4, 2021

@rafiss
Copy link
Collaborator Author

rafiss commented Feb 4, 2021

those tests are for telemetry i believe right? but this change is for metrics for the DB console

@otan
Copy link
Contributor

otan commented Feb 4, 2021

ah i see

@rafiss rafiss force-pushed the rollback-savepoint-metrics branch from 6e45553 to b468e87 Compare February 5, 2021 05:44
@rafiss rafiss requested a review from a team as a code owner February 5, 2021 05:44
@rafiss rafiss force-pushed the rollback-savepoint-metrics branch from b468e87 to 289bcb3 Compare February 5, 2021 16:34
@rafiss
Copy link
Collaborator Author

rafiss commented Feb 5, 2021

i added a test that goes through the HTTP _status/vars interface since i couldn't find any other place it would go

RFAL

@rafiss rafiss requested a review from arulajmani February 8, 2021 20:16
@rafiss
Copy link
Collaborator Author

rafiss commented Feb 8, 2021

@arulajmani I requested your review you since you steered me in the general direction of those tests -- lmk what you think

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten and @rafiss)


pkg/server/status_test.go, line 1195 at r1 (raw file):

		}
		if !bytes.Contains(body, []byte("sql_txn_rollback_count 0")) {
			return errors.Errorf("expected `sql_txn_rollback_count 0`, got: %s", body)

Should we check that the sql.txn.commit.count has been incremented to 1 as well?

Copy link
Collaborator Author

@rafiss rafiss 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 @arulajmani and @nvanbenschoten)


pkg/server/status_test.go, line 1195 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Should we check that the sql.txn.commit.count has been incremented to 1 as well?

yes good call. though actually it is expected to be 0 since it only counts COMMIT statements. in this case, sql_restart_savepoint_release_count is used instead of COMMIT, but i will still add the assertion we expect

@rafiss rafiss force-pushed the rollback-savepoint-metrics branch from 289bcb3 to 23e3f7a Compare February 8, 2021 22:52
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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/server/status_test.go, line 1195 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

yes good call. though actually it is expected to be 0 since it only counts COMMIT statements. in this case, sql_restart_savepoint_release_count is used instead of COMMIT, but i will still add the assertion we expect

Maybe I'm misunderstanding something, but @nvanbenschoten's comment on the issue seems to imply that sql.txn.commit.count should be incremented.

Copy link
Collaborator Author

@rafiss rafiss 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 @nvanbenschoten)


pkg/server/status_test.go, line 1195 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Maybe I'm misunderstanding something, but @nvanbenschoten's comment on the issue seems to imply that sql.txn.commit.count should be incremented.

yikes i missed that! yes i will make the code do that then

Release note (bug fix): Previously if `RELEASE SAVEPOINT
cockroach_restart` was followed by `ROLLBACK`, the
`sql.txn.rollback.count` metric would be incremented. This was
incorrect, since the txn had already committed. Now that metric is not
incremented in this case.
@rafiss rafiss force-pushed the rollback-savepoint-metrics branch from 23e3f7a to 6b60a69 Compare February 9, 2021 05:41
@rafiss rafiss requested a review from arulajmani February 9, 2021 15:50
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:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)

@rafiss
Copy link
Collaborator Author

rafiss commented Feb 9, 2021

thanks for reviewing!

bors r=arulajmani

@craig
Copy link
Contributor

craig bot commented Feb 9, 2021

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
Development

Successfully merging this pull request may close these issues.

sql,metrics: ROLLBACK after RELEASE cockroach_restart misclassified in metrics
4 participants