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

Some tiered storage refactorings setting up more work #13230

Closed

Conversation

pdillinger
Copy link
Contributor

@pdillinger pdillinger commented Dec 19, 2024

Summary:

  • Simplify some testing callbacks for tiered_compaction_test ahead of some significant functional updates.
  • Refactor CompactionJob::Prepare() for sharing with CompactionServiceCompactionJob. This is a minor functional change in computing preserve/preclude sequence numbers for remote compaction, but it is a start toward support for tiered storage with remote compaction. A test is added that is only partly working but does check that outputs are being split (just not to the correct levels).

Test Plan: mostly test changes and additions. Arguably makes tiered storage + remote compaction MORE broken as a step toward supporting it.

Summary:
* Simplify some testing callbacks for tiered_compaction_test ahead
of some significant functional updates.
* Split up CompactionJob::Prepare() so that the relevant part
can be used in CompactionServiceCompactionJob. This is a minor
functional change that is a start toward support for tiered storage with
remote compaction. A test is added that is only partly working but does
check that outputs are being split (just not to the correct levels).

Test Plan: mostly test changes and additions. Arguably makes tiered
storage + remote compaction MORE broken as a step toward supporting it.
// Prepare for the compaction by setting up boundaries for each subcompaction
void Prepare();
// Prepare for the compaction by setting up boundaries for each subcompaction.
// At present this is *not* called by CompactionServiceCompactionJob.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -245,7 +245,7 @@ void CompactionJob::ReportStartedCompaction(Compaction* compaction) {
compaction_job_stats_->is_full_compaction = compaction->is_full_compaction();
}

void CompactionJob::Prepare() {
void CompactionJob::PrepareSubs() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we weren't doing this before, but since we are making changes here now. Do we want to add a quick assertion to make sure mutex is held? And same for PrepareTimes()

db_mutex_->AssertHeld();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the call-out as I was violating my own (somewhat copied) contract and that could have been a race.

Copy link
Contributor

@jaykorean jaykorean left a comment

Choose a reason for hiding this comment

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

I know that you are looking into the clang-format and I assume that you will rebase after #13233 . The change LGTM. Thanks!

@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@@ -280,13 +284,15 @@ void CompactionJob::Prepare() {
RecordInHistogram(stats_, NUM_SUBCOMPACTIONS_SCHEDULED,
compact_->sub_compact_states.size());
} else {
compact_->sub_compact_states.emplace_back(c, std::nullopt, std::nullopt,
auto single_subcompact = known_single_subcompact.value_or(
std::make_pair(std::optional<Slice>{}, std::optional<Slice>{}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Question for my own learning. I believe that std::optional<Slice>{} would also return false for has_value(). This just explicitly shows the intention of creating an empty optional Slice. Please correct me if I am wrong.

Copy link
Contributor Author

@pdillinger pdillinger Dec 20, 2024

Choose a reason for hiding this comment

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

I guess the code is a little too clever in dealing with the nested optionals etc. I'll rewrite it. (single_subcompact is a pair at the top-level, while known_single_subcompact is an optional pair)

Copy link
Contributor

@jaykorean jaykorean left a comment

Choose a reason for hiding this comment

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

Thank you!

@facebook-github-bot
Copy link
Contributor

@pdillinger has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pdillinger merged this pull request in 54b614d.

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