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 condition on NotifyOnFlushComplete that FlushJob was not mempurge. Add event listeners to mempurge tests. #8672

Closed
wants to merge 7 commits into from

Conversation

bjlemaire
Copy link
Contributor

Previously, when a FlushJob was redirected to a MemPurge, the function DBImpl::NotifyOnFlushComplete was called, which created a series of issues because the JobInfo was not correctly collected from the memtables.
This diff aims at correcting these two issues (FlushJobInfo collection in FlushJob::MemPurge , no call to DBImpl::NotifyOnFlushComplete after successful mempurge).
Event listeners were added to the unit tests to handle these situations.
Surprisingly none of the crashtests caught this issue, I will try to add event listeners to crash tests in the future.

@bjlemaire
Copy link
Contributor Author

I use uint8_t instead of bool solely because vector<bool> is a special variable that created a lot of issues when I tried to make calls with &switched_to_mempurge[i] (or switched_to_mempurge.data()+i) in DBimpl::AtomicMemFlush[...].
Definitely interested in hearing what people say about that, if using uint8_t is too confusing or not.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@@ -411,6 +414,7 @@ Status DBImpl::AtomicFlushMemTablesToOutputFiles(
}

std::vector<FileMetaData> file_meta(num_cfs);
std::vector<uint8_t> switched_to_mempurge(num_cfs, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be 0 instead of false? I don't think it will make any difference apart from readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, thanks for catching that, I was trying to use bools the whole time so that's just a remnant of what I used before switching to uint8_t.

db/flush_job.cc Outdated
@@ -228,6 +228,9 @@ Status FlushJob::Run(LogsWithPrepTracker* prep_tracker,
prev_cpu_read_nanos = IOSTATS(cpu_read_nanos);
}
Status mempurge_s = Status::NotFound("No MemPurge.");
if (switched_to_mempurge) {
*switched_to_mempurge = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to set it or it will be 0 by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is 0 by default, I added this out of paranoia. It's probably cleaner to remove this you are right, thanks for your input.

} else {
// The mempurge process was successful, but no switch_to_mempurge
// pointer provided so no way to propagate the state of flush job.
ROCKS_LOG_WARN(db_options_.info_log,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, what are the reasons that switched_to_mempurge is not provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good question. The first two arguments of FlushJob::Run, prep_tracker and file_meta, are already optional arguments, so adding a third argument required a default value as well.
In practice, the only moment sin the current code base when Run() (aka no arguments provided, including no switched_to_mempurge) is called is in flush_job_test.cc, so I am (arguably) hesitant to make it a required argument for this reason.

Copy link
Contributor

@akankshamahajan15 akankshamahajan15 Aug 18, 2021

Choose a reason for hiding this comment

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

Makes sense. Thanks for clarifying it.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@akankshamahajan15 akankshamahajan15 left a comment

Choose a reason for hiding this comment

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

LGTM!

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@bjlemaire bjlemaire force-pushed the piggyback_flushjobinfo branch from afb0037 to 90f1444 Compare August 18, 2021 20:54
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@bjlemaire merged this pull request in c625b8d.

yoori pushed a commit to yoori/rocksdb that referenced this pull request Nov 26, 2023
…. Add event listeners to mempurge tests. (#8672)

Summary:
Previously, when a `FlushJob` was redirected to a MemPurge, the function `DBImpl::NotifyOnFlushComplete` was called, which created a series of issues because the JobInfo was not correctly collected from the memtables.
This diff aims at correcting these two issues (`FlushJobInfo` collection in `FlushJob::MemPurge` , no call to `DBImpl::NotifyOnFlushComplete` after successful mempurge).
Event listeners were added to the unit tests to handle these situations.
Surprisingly none of the crashtests caught this issue, I will try to add event listeners to crash tests in the future.

Pull Request resolved: facebook/rocksdb#8672

Reviewed By: akankshamahajan15

Differential Revision: D30383109

Pulled By: bjlemaire

fbshipit-source-id: 35a8d4295886923ee4049a6447f00022cb221c73
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