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: remove EvalContext.ActiveMemAcc #34935

Merged
merged 1 commit into from
Feb 21, 2019

Conversation

jordanlewis
Copy link
Member

This memory account was used to track allocations performed by builtins
that allocated memory, mainly string manipulation builtins. It was
pretty hard to use this correctly, as the lifetimes of the account were
never particularly clear.

There were a couple of hacks in place to try to clear the memory at the
right times, but they didn't work correctly, leading to crashes that
were hard to diagnose.

Rather than try to make this work perfectly, this commit removes the
memory accounting for these builtins and replaces it with a hard cap on
the size of string allocations - set arbitrarily to 64 MB at this time.

Release note: None

@jordanlewis jordanlewis requested review from justinj, knz, RaduBerinde and a team February 14, 2019 23:01
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@justinj
Copy link
Contributor

justinj commented Feb 15, 2019

LGTM
hankscorpio

@jordanlewis jordanlewis force-pushed the rm-activememacc branch 2 times, most recently from 239aa4c to 8019ace Compare February 20, 2019 23:26
@jordanlewis
Copy link
Member Author

TFTR @justinj!

@knz pinging you directly if you want to take a look since I know you care about this issue - I'd like to merge this soon.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM with a nit on the message presented to the user, see suggestion below

Reviewed 18 of 18 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis, @justinj, and @RaduBerinde)


pkg/sql/sem/builtins/builtins.go, line 72 at r1 (raw file):

	errChrValueTooLarge = pgerror.NewErrorf(pgerror.CodeInvalidParameterValueError,
		"input value must be <= %d (maximum Unicode code point)", utf8.MaxRune)
	errStringTooLarge = pgerror.NewErrorf(pgerror.CodeProgramLimitExceededError, "requested length too large")

maybe NewErrorf(..., "result too large, value size exceeds %s", humanizeutil.IBytes(maxAllocatedStringsize)

this way the user knows more clearly what's going on.

@jordanlewis
Copy link
Member Author

I kept the message like that to achieve Postgres compatibility, but I'll take your advice.

This memory account was used to track allocations performed by builtins
that allocated memory, mainly string manipulation builtins. It was
pretty hard to use this correctly, as the lifetimes of the account were
never particularly clear.

There were a couple of hacks in place to try to clear the memory at the
right times, but they didn't work correctly, leading to crashes that
were hard to diagnose.

Rather than try to make this work perfectly, this commit removes the
memory accounting for these builtins and replaces it with a hard cap on
the size of string allocations - set arbitrarily to 64 MB at this time.

Release note: None
@jordanlewis
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Feb 21, 2019
34935: sql: remove EvalContext.ActiveMemAcc r=jordanlewis a=jordanlewis

This memory account was used to track allocations performed by builtins
that allocated memory, mainly string manipulation builtins. It was
pretty hard to use this correctly, as the lifetimes of the account were
never particularly clear.

There were a couple of hacks in place to try to clear the memory at the
right times, but they didn't work correctly, leading to crashes that
were hard to diagnose.

Rather than try to make this work perfectly, this commit removes the
memory accounting for these builtins and replaces it with a hard cap on
the size of string allocations - set arbitrarily to 64 MB at this time.

Release note: None

35074: opt: logical props and stats for merge join r=RaduBerinde a=RaduBerinde

Wire up the code for logical props and stats to work with merge joins.
This is useful with exprgen.

Release note: None

35075: opt: add parallel test for create stats r=RaduBerinde a=RaduBerinde

Adding a test where three nodes run CREATE STATS multiple times (in
parallel) on the same table.

Fixes #34781.

Release note: None

Co-authored-by: Jordan Lewis <[email protected]>
Co-authored-by: Radu Berinde <[email protected]>
@craig
Copy link
Contributor

craig bot commented Feb 21, 2019

Build succeeded

@jordanlewis jordanlewis deleted the rm-activememacc branch February 22, 2019 14:12
thoszhang pushed a commit to thoszhang/cockroach that referenced this pull request Mar 12, 2019
Add regression tests for a bug where backfilling a computed column or a column
with a default value using a builtin function would cause a `memory budget
exceeded` error (cockroachdb#34901). This was fixed by cockroachdb#34935.

Release note: None
thoszhang pushed a commit to thoszhang/cockroach that referenced this pull request Mar 12, 2019
Add regression tests for a bug where backfilling a computed column or a column
with a default value using a builtin function would cause a `memory budget
exceeded` error (cockroachdb#34901). This was fixed by cockroachdb#34935.

Release note: None
craig bot pushed a commit that referenced this pull request Mar 12, 2019
35565: sqlsmith: various improvements r=mjibson a=mjibson



35662: sql: add regression tests for memory accounting bug r=lucy-zhang a=lucy-zhang

Add regression tests for a bug where backfilling a computed column or a column
with a default value using a builtin function would cause a `memory budget
exceeded` error (#34901). This was fixed by #34935.

Release note: None

Co-authored-by: Matt Jibson <[email protected]>
Co-authored-by: Lucy Zhang <[email protected]>
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