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

storage: add cache target estimates and space management control loop skeleton #11133

Merged
merged 5 commits into from
Jun 7, 2023

Conversation

dotnwat
Copy link
Member

@dotnwat dotnwat commented Jun 1, 2023

Adds a cloud cache interface for estimating the target minimum for storage size, as well as a control loop skeleton which will be used to manage disk space to be added in subsequent PR.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.1.x
  • v22.3.x
  • v22.2.x

Release Notes

  • none

@dotnwat dotnwat requested review from jcsp, andrwng and VladLazar and removed request for jcsp and andrwng June 1, 2023 02:03
@dotnwat dotnwat requested a review from andrwng June 1, 2023 02:03
@dotnwat
Copy link
Member Author

dotnwat commented Jun 1, 2023

Force-push:

  • Fixed circular dependency in the shared library build.

andrwng
andrwng previously approved these changes Jun 2, 2023
Copy link
Contributor

@andrwng andrwng left a comment

Choose a reason for hiding this comment

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

LGTM, nothing blocking

Comment on lines 1123 to 1136
auto [size, chunked] = seg->min_cache_cost();
if (chunked) {
return cache_usage{
.target_min_bytes = min_chunks * size,
.target_bytes = wanted_chunks * size,
};
} else {
return cache_usage{
.target_min_bytes = min_segments * size,
.target_bytes = wanted_segments * size,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider making min_cache_cost() return the usage, to avoid this chunked out bool? Especially if there's any appetite for making min_* and wanted_* configurable, it seems pretty natural to make the segment encapsulate this

co_await _gate.close();
}

ss::future<> disk_space_manager::controller() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we avoid using "controller"? Maybe run_loop or something? Especially if this at some point makes its way into cluster/

Copy link
Member Author

Choose a reason for hiding this comment

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

yep. fixed

Comment on lines +1843 to +1849
, enable_storage_space_manager(
*this,
"enable_storage_space_manager",
"Enable the storage space manager that coordinates and control space "
"usage between log data and the cloud storage cache.",
{.needs_restart = needs_restart::no, .visibility = visibility::user},
true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the behavior you're implementing warrant doing anything differently in the face of skew, but I'm curious if you've given thought to whether this should be configurable/controllable at the node level. A few scenarios come to mind when space usage may vary across nodes

  • when there is some hypothetical retention bug that consumes the space on a a single node but not others
  • when there is heterogeneous hardware
  • when there is severe partition-size skew

Just thinking whether during an incident it'll be desirable to have a way to flip this off for one but not all nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

this makes a lot of sense. i'd even assume that we'd want to be able to turn it off on a per node basis without needing a restart. at least i think that we dont' allow that later feature so we'd need an admin endpoint.

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've added a ticket to track this here. It's a good idea: #11192

@@ -1101,4 +1103,79 @@ materialized_segments& remote_partition::materialized() {
return _api.materialized();
}

cache_usage remote_partition::get_cache_usage() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming: something other than usage will be easier to understand (usually usage means how much space we're using, but this is really asking for target usage, or some other noun if we can think of one)

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
A segment may be in legacy mode or chunked mode which will affect the
way that it interacts with the cloud cache. This patch adds an interface
for exposing this aspect of the state of the segment.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Adds an interface for estimating the target minimum / wanted sizes for a
remote partition in the cloud storage cache.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Introduces a new disk space manager control loop that has access to both
the cloud storage cache as well as log storage for the purposes of
managing free space.

This commit only introduces the control loop and prints storage
statistics collected from the subsystem using our new APIs at debug
level.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
@dotnwat
Copy link
Member Author

dotnwat commented Jun 4, 2023

Force push 1:

  • Fix naming of usage/target per Johns suggestion
  • Fixed naming of control loop per Andrews suggestion
  • Updated tests to handle recent v2/v3 changes from Abhijat

Force push 2:

  • Forgot to squash commits

@dotnwat dotnwat requested review from jcsp and andrwng June 5, 2023 04:16
@dotnwat
Copy link
Member Author

dotnwat commented Jun 7, 2023

Ping @andrwng

Copy link
Contributor

@andrwng andrwng left a comment

Choose a reason for hiding this comment

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

LGTM!

@dotnwat dotnwat merged commit 63a74ca into redpanda-data:dev Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants