Skip to content

opt: reset Implicator constraint cache in Init#58306

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
mgartner:reset-implicator-constraint-cache
Dec 28, 2020
Merged

opt: reset Implicator constraint cache in Init#58306
craig[bot] merged 1 commit intocockroachdb:masterfrom
mgartner:reset-implicator-constraint-cache

Conversation

@mgartner
Copy link
Copy Markdown
Contributor

The Implicator's constraint cache is now cleared when Init is called.
This prevents the constraint cache from growing indefinitely.

Release justification: This is a simple fix that prevents memory leaks
in the optimizer when planning queries on tables with partial indexes.

Release note (bug fix): A memory leak in the optimizer has been fixed.
The leak could have caused unbounded growth of memory usage for a
session when planning queries on tables with partial indexes.

The Implicator's constraint cache is now cleared when `Init` is called.
This prevents the constraint cache from growing indefinitely.

Release justification: This is a simple fix that prevents memory leaks
in the optimizer when planning queries on tables with partial indexes.

Release note (bug fix): A memory leak in the optimizer has been fixed.
The leak could have caused unbounded growth of memory usage for a
session when planning queries on tables with partial indexes.
@mgartner mgartner requested a review from a team as a code owner December 28, 2020 18:08
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde 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 @andy-kimball, @RaduBerinde, and @rytaft)

@mgartner
Copy link
Copy Markdown
Contributor Author

bors r=RaduBerinde

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 28, 2020

Build succeeded:

@craig craig bot merged commit 4008383 into cockroachdb:master Dec 28, 2020
@mgartner mgartner deleted the reset-implicator-constraint-cache branch December 29, 2020 00:47
mgartner added a commit to mgartner/cockroach that referenced this pull request Dec 31, 2020
We commonly use a pattern of declaring structs and then initializing
them via an `Init` method. This allows internal data structures to be
reused, reducing allocations. However, the common initialization
implementation is dangerous because fields are implicitly reused. This
can lead to inconspicuous bugs (see cockroachdb#58306).

This commit introduces a new pattern for initialization functions that
requires reused fields to be explicitly listed. This should reduce the
risk of these types of bugs.

Release note: None
craig bot pushed a commit that referenced this pull request Jan 4, 2021
58386: opt: use safer struct initialization pattern r=rytaft a=mgartner

We commonly use a pattern of declaring structs and then initializing
them via an `Init` method. This allows internal data structures to be
reused, reducing allocations. However, the common initialization
implementation is dangerous because fields are implicitly reused. This
can lead to inconspicuous bugs (see #58306).

This commit introduces a new pattern for initialization functions that
requires reused fields to be explicitly listed. This should reduce the
risk of these types of bugs.

Release note: None

Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
@rafiss rafiss added this to the 20.2 milestone Apr 22, 2021
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