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 cache reservation logic #6350

Merged

Conversation

kotwanikunal
Copy link
Member

@kotwanikunal kotwanikunal commented Feb 17, 2023

Description

  • This PR focuses on adding a reservation logic for the cache introduced as a part of searchable snapshots
  • The design was defined as a part of [Searchable Snapshot] Design file caching mechanism for block based files #4964 where a user can define the cache size using node.search.cache.size configuration for the node
  • This value is persisted as a part of the NodePath for the first data path configured on the node, and defaults to 100 MB otherwise.

Issues Resolved

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)

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.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT.testIndexCreateBlockIsRemovedWhenAnyNodesNotExceedHighWatermarkWithAutoReleaseEnabled

For a remote snapshot index, the cache path is used to initialize the shards.
For a local index, a local shard path is loaded or a new path is calculated.
*/
private ShardPath getShardPath(ShardRouting routing, ShardId shardId, ShardLock lock) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

What was the purpose of this refactoring? This is a private method that is only called from one place, so why break it into a separate method in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did it for better readability. The initialization block was a lot of loading the shard path. This makes it easier to walk through that logic as a unit.

server/src/main/java/org/opensearch/monitor/fs/FsInfo.java Outdated Show resolved Hide resolved
@kotwanikunal kotwanikunal force-pushed the cache-reservation branch 2 times, most recently from 4670c01 to c7d7e70 Compare February 24, 2023 20:12
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@kotwanikunal kotwanikunal force-pushed the cache-reservation branch 2 times, most recently from d59bc75 to b409918 Compare February 24, 2023 21:44
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@andrross andrross left a comment

Choose a reason for hiding this comment

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

One minor comment

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

Codecov Report

Merging #6350 (b409918) into main (261f22c) will decrease coverage by 0.04%.
The diff coverage is 63.33%.

❗ Current head b409918 differs from pull request most recent head 60eb37f. Consider uploading reports for the commit 60eb37f to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #6350      +/-   ##
============================================
- Coverage     70.76%   70.73%   -0.04%     
+ Complexity    59065    59062       -3     
============================================
  Files          4801     4801              
  Lines        282816   282901      +85     
  Branches      40773    40787      +14     
============================================
- Hits         200134   200100      -34     
- Misses        66273    66372      +99     
- Partials      16409    16429      +20     
Impacted Files Coverage Δ
...in/java/org/opensearch/indices/IndicesService.java 62.99% <ø> (+0.25%) ⬆️
.../java/org/opensearch/test/InternalTestCluster.java 58.41% <12.50%> (+0.76%) ⬆️
...rc/main/java/org/opensearch/monitor/fs/FsInfo.java 72.13% <31.25%> (-2.87%) ⬇️
...org/opensearch/common/settings/SettingsModule.java 83.55% <40.00%> (-0.91%) ⬇️
...src/main/java/org/opensearch/node/NodeService.java 70.31% <50.00%> (+0.47%) ⬆️
...c/main/java/org/opensearch/index/IndexService.java 73.64% <62.50%> (-0.90%) ⬇️
.../main/java/org/opensearch/env/NodeEnvironment.java 75.21% <68.85%> (-0.96%) ⬇️
server/src/main/java/org/opensearch/node/Node.java 83.57% <75.00%> (-0.08%) ⬇️
...c/main/java/org/opensearch/monitor/fs/FsProbe.java 84.37% <90.00%> (+1.61%) ⬆️
...ava/org/opensearch/cluster/node/DiscoveryNode.java 91.80% <100.00%> (+0.59%) ⬆️
... and 488 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@kotwanikunal kotwanikunal merged commit eb78246 into opensearch-project:main Feb 24, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-6350-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 eb78246b93766e31a47112ab01872fc2d9052374
# Push it to GitHub
git push --set-upstream origin backport/backport-6350-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-6350-to-2.x.

kotwanikunal added a commit to kotwanikunal/OpenSearch that referenced this pull request Feb 24, 2023
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
(cherry picked from commit eb78246)
@kotwanikunal
Copy link
Member Author

Backport: #6485

andrross pushed a commit that referenced this pull request Feb 25, 2023
* Include file cache stats in node stats response (#6333)

This change exposes the file cache stats as part the node stats API response.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
(cherry picked from commit 0f3b870)

* Add cache reservation logic (#6350)

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
(cherry picked from commit eb78246)

---------

Co-authored-by: Rabi Panda <adnapibar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Searchable Snapshot] Implement disk reservation logic to be used for local file system cache
4 participants