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 capability to manually flush memtable and l0 #520

Closed
wants to merge 1 commit into from

Conversation

alxyang
Copy link
Contributor

@alxyang alxyang commented Feb 3, 2017

This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at #427.

@update-submodule: rocksdb

@facebook-github-bot
Copy link

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

std::vector<std::string> file_names;
for (auto &file : metadata.levels[0].files) {
DBUG_ASSERT(metadata.levels[0].level == 0);
file_names.emplace_back(file.db_path + "/" + file.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems odd that db_path doesn't end in '/', but I do see code in rocksdb adding '/' between path and filename in some cases. I assume the "/" is required to assemble the full path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it seems so. I used https://github.com/facebook/rocksdb/blob/master/db/compact_files_test.cc#L105 as my reference which is doing pretty much the exact same thing we want here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I stepped through in GDB and found that actually the "/" isn't required (even though the test case above uses it).

It parses the number from the sst file during CompactFiles() using https://github.com/facebook/rocksdb/blob/master/db/filename.cc#L99-L108.

So I'll remove the extra "/" even though it doesn't hurt really

if (file_names.size() > 0) {
rocksdb::Status s;
s = rdb->CompactFiles(rocksdb::CompactionOptions(), cf_handle, file_names,
metadata.levels.size() - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this target level 1 for the output, instead of the bottommost level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, no problem.

@facebook-github-bot
Copy link

@alxyang updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link

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

file_names.emplace_back(file.db_path + file.name);
}

if (file_names.size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - I have small preference for if (!file_names.empty()) {. Not for performance - I just think it is easier to read.

std::vector<std::string> file_names;
for (auto &file : metadata.levels[0].files) {
DBUG_ASSERT(metadata.levels[0].level == 0);
file_names.emplace_back(file.db_path + file.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is file.db_path guaranteed to end with a '/'? The reason I ask is RocksDB's own tests add a '/' in the middle. https://github.com/facebook/rocksdb/blob/master/db/compact_files_test.cc#L104-L107

Copy link
Contributor Author

@alxyang alxyang Mar 20, 2017

Choose a reason for hiding this comment

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

Originally I did put a / there. @hermanlee commented above asking if it was necessary, I stepped through GDB and found that it was not. See my comment above for more details.

See https://github.com/facebook/rocksdb/blob/master/db/filename.cc#L99-L108 for how the sstfile name is parsed.

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem. As long as it has been checked.

static int rocksdb_force_flush_memtable_and_lzero_now(
THD *const thd, struct st_mysql_sys_var *const var, void *const var_ptr,
struct st_mysql_value *const value) {
sql_print_information("RocksDB: Manual memtable and L0 flush\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

The sql_print_information() function automatically adds a '\n' to the end of the string that you pass it. Unless you are intentionally trying to add an empty line in the log file after this line you should remove the '\n' here. Note that rocksdb_force_flush_memtable_now() should probably be changed as well.


std::vector<std::string> file_names;
for (auto &file : metadata.levels[0].files) {
DBUG_ASSERT(metadata.levels[0].level == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this assert inside the inner for loop? I would expect that checking this once in the outer for loop would be sufficient.


if (file_names.size() > 0) {
rocksdb::Status s;
s = rdb->CompactFiles(rocksdb::CompactionOptions(), cf_handle, file_names,
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that rocksdb::CompactionOptions() will not change throughout both the inner and the outer loop. Can we put this into a local variable to avoid calling it over and over?

const Rdb_cf_manager &cf_manager = rdb_get_cf_manager();
for (const auto &cf_handle : cf_manager.get_all_cf()) {
rocksdb::ColumnFamilyMetaData metadata;
rdb->GetColumnFamilyMetaData(cf_handle, &metadata);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is guaranteeing that the data inside metadata is not being changed while we are reading it? Is this known to be safe?

Copy link
Contributor

Choose a reason for hiding this comment

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

When calling into GetColumnFamilyMetaData() the current SuperVersion is referenced and the metadata is copied over from that. When the function exits the SuperVersion is de-referenced. A SuperVersion represents an immutable state of the database (when the manifest is updated). It is possible, however, that we are not the first to request that a given L0 file be compacted. This would cause CompactFiles to error out.

It is also possible that by the time we request to have a file flushed the file has been deleted because we have de-referenced the SuperVersion from which the metadata was copied. To solve this we should hold our own superversion reference and copy over the metadata ourselves.

This still doesn't seem like an issue to me considering this is to be used for performance testing/debugging. There is no copy-race condition and CompactFiles() should gracefully handle all sanity checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested a few things, like passing in an SST file that no longer exists, or trying to compact a level that doesnt exist, and in both cases CompactFiles handled it gracefully.

It'll write something to the logs like so:

2017-03-20 18:26:50 2306114 [Warning] MyRocks: failed to read/write in RocksDB. Error type = RDB_IO_ERROR_GENERAL, stat
us code = 4, status = Invalid argument: Specified compaction input file /000099.sst does not exist in column family def
ault.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right - metadata is a copy. I should have seen that.

@facebook-github-bot
Copy link

@alxyang updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link

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

@facebook-github-bot
Copy link

@alxyang updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link

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

IslamAbdelRahman pushed a commit to IslamAbdelRahman/mysql-5.6 that referenced this pull request May 31, 2017
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520
Github Author: Alex Yang <alexyang@fb.com>

Github PR Sync: {sync, type="child", parent="github", parentrepo="facebook/mysql-5.6", parentprnum="520", parentprfbid="156908684811954"}

Test Plan: Imported from GitHub, without a `Test Plan:` line.

Reviewers: herman, jkedgar, svcscm

Reviewed By: svcscm

Subscribers: svcscm, webscalesql-eng@fb.com

Differential Revision: https://phabricator.intern.facebook.com/D4509351

Signature: t1:4509351:1490814923:d177f0faf2cc11c4e76afd5399343a34c152fd74
george-lorch pushed a commit to george-lorch/percona-server that referenced this pull request Jul 19, 2017
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
george-lorch pushed a commit to george-lorch/percona-server that referenced this pull request Jul 20, 2017
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
george-lorch pushed a commit to george-lorch/percona-server that referenced this pull request Jul 21, 2017
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
george-lorch pushed a commit to george-lorch/percona-server that referenced this pull request Jul 21, 2017
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
gunnarku pushed a commit to facebook/mysql-8.0 that referenced this pull request Jul 21, 2017
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
gunnarku pushed a commit to facebook/mysql-8.0 that referenced this pull request Jul 25, 2017
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: 3f04f3c
facebook-github-bot pushed a commit that referenced this pull request Dec 23, 2019
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at #427.

update-submodule: rocksdb
Closes #520

Differential Revision: D4509351

Pulled By: alxyang

fbshipit-source-id: dd3c711
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 12, 2020
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Sep 9, 2020
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Sep 16, 2020
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Oct 5, 2020
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Nov 11, 2020
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
facebook-github-bot pushed a commit that referenced this pull request Mar 8, 2021
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at #427.

update-submodule: rocksdb
Closes #520

Differential Revision: D4509351 (44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 16, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 17, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 30, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 30, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Sep 1, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Sep 2, 2021
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351 (facebook@44a522c)

Pulled By: alxyang

fbshipit-source-id: c5de1697c40
hermanlee pushed a commit that referenced this pull request Jan 10, 2022
Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at #427.

@update-submodule: rocksdb
Closes #520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jan 17, 2022
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Mar 15, 2022
…na#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

@update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 20, 2022
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 23, 2022
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
laurynas-biveinis pushed a commit to laurynas-biveinis/mysql-5.6 that referenced this pull request Aug 11, 2022
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Mar 28, 2023
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jun 1, 2023
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jun 14, 2023
…book#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook#427.

@update-submodule: rocksdb
Closes facebook#520

Differential Revision: D4509351

Pulled By: alxyang
inikep pushed a commit to inikep/percona-server that referenced this pull request Apr 9, 2024
…na#520)

Summary:
This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring.

See more details at facebook/mysql-5.6#427.

@update-submodule: rocksdb
Closes facebook/mysql-5.6#520

Differential Revision: D4509351

Pulled By: alxyang
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.

None yet

5 participants