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

Add query parameters to delete request cache on heap and disk selectively #15

Conversation

kiranprakash154
Copy link
Collaborator

@kiranprakash154 kiranprakash154 commented Dec 12, 2023

Description

With Tiered caching[Add Link], we will now have multiple tiers of caches, for now it is heap and disk.
We are exposing a way to clear the cache selectively.

Earlier:
POST /my-index/_cache/clear?request=true - would clear the entire request cache.

Now:
POST /my-index/_cache/clear?request=true - will clear the entire request cache (heap & disk, if disk is enabled)

New parameters
POST /my-index/_cache/clear?requestCacheOnDisk=true - will clear the request cache on disk tier only
POST /my-index/_cache/clear?requestCacheOnHeap=true - will clear the request cache on heap tier only
POST /my-index/_cache/clear?requestCacheOnDisk=true&requestCacheOnHeap=true - would clear the entire request cache (heap & disk, if disk is enabled)

Valid calls:
POST /my-index/_cache/clear?requestCacheOnDisk=true
POST /my-index/_cache/clear?requestCacheOnHeap=true
POST /my-index/_cache/clear?request=true
POST /my-index/_cache/clear?requestCacheOnDisk=true&requestCacheOnHeap=true

Invalid calls:
POST /my-index/_cache/clear?requestCacheOnDisk=true&request=true
POST /my-index/_cache/clear?requestCacheOnHeap=true&request=true

image

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@kiranprakash154 kiranprakash154 changed the title staleKp/cache clear disk from stale branch Add query parameters to delete cache on heap and disk selectively Dec 12, 2023

package org.opensearch.action;

public interface InputValidator {
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like something like this must already exist somewhere... seems like a general problem that many APIs would have to solve


public void validateInput() {
if (requestCache && requestCacheOnDisk) {
throw new IllegalArgumentException("Invalid parameters: cannot have both requestCache and requestCacheOnDisk set to true");
Copy link
Owner

Choose a reason for hiding this comment

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

Would these exceptions actually reach whatever is returned to the user who made the poorly formatted API call?

Copy link
Collaborator Author

@kiranprakash154 kiranprakash154 Dec 15, 2023

Choose a reason for hiding this comment

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

Ya it does
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

btw i changed requestCache to request in the error because the flag we pass to clear all entire requestcache is request.

@kiranprakash154 kiranprakash154 self-assigned this Dec 18, 2023
Copy link

@sgup432 sgup432 left a comment

Choose a reason for hiding this comment

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

Can you add more details in the description?
Like url exposed, testing done etc.

Comment on lines +161 to +168
public void validateInput() {
if (requestCache && requestCacheOnDisk) {
throw new IllegalArgumentException("Invalid parameters: cannot have both request and requestCacheOnDisk set to true");
}
if (requestCache && requestCacheOnHeap) {
throw new IllegalArgumentException("Invalid parameters: cannot have both request and requestCacheOnHeap set to true");
}
}
Copy link

Choose a reason for hiding this comment

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

Lets remove this for now and keep it consistent with rest of the actions. Move this logic to the actual function.
Doesn't look much useful to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the validity of the ClearIndicesCacheRequest should be scoped to the ClearIndicesCacheRequest class right ?
the caller of this class i.e RestClearIndicesCacheAction should not be concerned about that.

@kiranprakash154
Copy link
Collaborator Author

Can you add more details in the description? Like url exposed, testing done etc.

Yep, I should have done it.

@kiranprakash154 kiranprakash154 changed the title Add query parameters to delete cache on heap and disk selectively Add query parameters to delete request cache on heap and disk selectively Dec 21, 2023
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