Skip to content

util/mon: augment "budget exceeded" errors from root monitor with a hint#81859

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:error-hint
May 26, 2022
Merged

util/mon: augment "budget exceeded" errors from root monitor with a hint#81859
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:error-hint

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

This commit adjusts the root SQL memory monitor to return "budget
exceeded" errors with a hint about considering increasing the
--max-sql-memory startup argument. This should hopefully help the
users to be a bit more self-sufficient.

Here is an example error from SQL shell:

ERROR: scan with start key /Table/105/2/0: root: memory budget exceeded: 4198400 bytes requested, 4689920 currently allocated, 8388608 bytes in budget
SQLSTATE: 53200
HINT: Consider increasing --max-sql-memory startup parameter.

Release note: None

@yuzefovich yuzefovich requested review from a team, cucaroach and mgartner May 25, 2022 20:28
@yuzefovich yuzefovich requested a review from a team as a code owner May 25, 2022 20:28
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

Thank you for doing this! :lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @cucaroach, @mgartner, and @yuzefovich)


pkg/util/mon/resource.go line 70 at r1 (raw file):

) error {
	return pgerror.WithCandidateCode(
		errors.WithHint(

nit: I believe errors.WithHint is allowed to wrap pgerror.WithCandidateCode, so you could put the latter in newMemoryBudgetExceededError.

This commit adjusts the root SQL memory monitor to return "budget
exceeded" errors with a hint about considering increasing the
`--max-sql-memory` startup argument. This should hopefully help the
users to be a bit more self-sufficient.

Here is an example error from SQL shell:
```
ERROR: scan with start key /Table/105/2/0: root: memory budget exceeded: 4198400 bytes requested, 4689920 currently allocated, 8388608 bytes in budget
SQLSTATE: 53200
HINT: Consider increasing --max-sql-memory startup parameter.
```

Release note: None
Copy link
Copy Markdown
Member Author

@yuzefovich yuzefovich 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 @cucaroach, @mgartner, and @michae2)


pkg/util/mon/resource.go line 70 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

nit: I believe errors.WithHint is allowed to wrap pgerror.WithCandidateCode, so you could put the latter in newMemoryBudgetExceededError.

Good point, done. I initially was afraid of not having the PG error code on the top-level error (since we expect it, e.g. in disk_spiller.go), but pgerror.GetPGCode still handles things correctly.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 26, 2022

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.

3 participants