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

Increase Size and lower TTL on DLS BitSet Cache #50535

Merged
merged 6 commits into from
Jan 13, 2020

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Dec 31, 2019

The Document Level Security BitSet Cache (see #43669) had a default
configuration of "small size, long lifetime". However, this is not
a very useful default as the cache is most valuable for BitSets that
take a long time to construct, which is (generally speaking) the same
ones that operate over a large number of documents and contain many
bytes.

This commit changes the cache to be "large size, short lifetime" so
that it can hold bitsets representing billions of documents, but
releases memory quickly.

The new defaults are 10% of heap, and 2 hours.

This also adds some logging when a single BitSet exceeds the size of
the cache and when the cache is full.

Resolves: #49260

The Document Level Security BitSet Cache (see elastic#43669) had a default
configuration of "small size, long lifetime". However, this is not
a very useful default as the cache is most valuable for BitSets that
take a long time to construct, which is (generally speaking) the same
ones that operate over a large number of documents and contain many
bytes.

This commit changes the cache to be "large size, short lifetime" so
that it can hold bitsets representing billions of documents, but
releases memory quickly.

The new defaults are 10% of heap, and 2 hours.

This also adds some logging when a single BitSet exceeds the size of
the cache and when the cache is full.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (:Security/Authorization)

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

LGTM - the prev value of 50Mb was too low and a ratio value makes sense to me. I don't feel qualified to answer about the 10% I don't have enough practical experience with real life memory numbers.
I sense it might be rather large, but the 2hrs expiry time should mitigate it.

I think we can expose to the DocumentSubsetBitsetCache that this roleQuery pertains from a script, and have a dedicated cache for those, i.e. a new Cache instance member. The original TTL of 1 week makes sense for non-templated role queries. However, templated role queries are rather difficult to set up and users that employ them really need them, which makes me assume they most likely use dynamic attributes of the user, or time, thereby flooding the cache which turns our 1 week TTL assumptions on their head.

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

The proposed size and TTL look good to me.

…security/authz/accesscontrol/DocumentSubsetBitsetCache.java

Co-Authored-By: Adrien Grand <jpountz@gmail.com>
@tvernum
Copy link
Contributor Author

tvernum commented Jan 13, 2020

Caused by: java.lang.AssertionError:
expected [2xx] status code but api [data_frame_transform_deprecated.stop_transform] returned [408 Request Timeout] [{"error":{"root_cause":[{"type":"status_exception","reason":"Could not stop the transforms [old-complex-transform] as they timed out

@elasticmachine run elasticsearch-ci/bwc

@tvernum tvernum merged commit 8a655f3 into elastic:master Jan 13, 2020
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Jan 14, 2020
The Document Level Security BitSet Cache (see elastic#43669) had a default
configuration of "small size, long lifetime". However, this is not
a very useful default as the cache is most valuable for BitSets that
take a long time to construct, which is (generally speaking) the same
ones that operate over a large number of documents and contain many
bytes.

This commit changes the cache to be "large size, short lifetime" so
that it can hold bitsets representing billions of documents, but
releases memory quickly.

The new defaults are 10% of heap, and 2 hours.

This also adds some logging when a single BitSet exceeds the size of
the cache and when the cache is full.

Resolves: elastic#49260
Backport of: elastic#50535
tvernum added a commit that referenced this pull request Jan 14, 2020
The Document Level Security BitSet Cache (see #43669) had a default
configuration of "small size, long lifetime". However, this is not
a very useful default as the cache is most valuable for BitSets that
take a long time to construct, which is (generally speaking) the same
ones that operate over a large number of documents and contain many
bytes.

This commit changes the cache to be "large size, short lifetime" so
that it can hold bitsets representing billions of documents, but
releases memory quickly.

The new defaults are 10% of heap, and 2 hours.

This also adds some logging when a single BitSet exceeds the size of
the cache and when the cache is full.

Backport of: #50535
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
The Document Level Security BitSet Cache (see elastic#43669) had a default
configuration of "small size, long lifetime". However, this is not
a very useful default as the cache is most valuable for BitSets that
take a long time to construct, which is (generally speaking) the same
ones that operate over a large number of documents and contain many
bytes.

This commit changes the cache to be "large size, short lifetime" so
that it can hold bitsets representing billions of documents, but
releases memory quickly.

The new defaults are 10% of heap, and 2 hours.

This also adds some logging when a single BitSet exceeds the size of
the cache and when the cache is full.

Resolves: elastic#49260
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Apr 29, 2022
In elastic#50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that tim, and still reflect the old values for
these settings
elasticsearchmachine pushed a commit that referenced this pull request May 2, 2022
In #50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
tvernum added a commit to tvernum/elasticsearch that referenced this pull request May 2, 2022
In elastic#50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
tvernum added a commit to tvernum/elasticsearch that referenced this pull request May 2, 2022
In elastic#50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
tvernum added a commit to tvernum/elasticsearch that referenced this pull request May 2, 2022
In elastic#50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
elasticsearchmachine pushed a commit that referenced this pull request May 2, 2022
In #50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
elasticsearchmachine pushed a commit that referenced this pull request May 2, 2022
In #50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
elasticsearchmachine pushed a commit that referenced this pull request May 2, 2022
In #50535 (ES v7.6) the default values for the
`DocumentSubsetBitsetCache` settings were changed. However, the docs
were not updated at that time, and still reflect the old values for
these settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better defaults for DocumentSubsetBitsetCache
5 participants