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

RemoteCompaction support Fallback to local compaction #8709

Closed
wants to merge 6 commits into from

Conversation

jay-zhuang
Copy link
Contributor

Summary: Add support for fallback to local compaction, the user can
return CompactionServiceJobStatus::kUseLocal to instruct RocksDB to
run the compaction locally instead of waiting for the remote compaction
result.

Test Plan: unittest

@facebook-github-bot
Copy link
Contributor

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

@jay-zhuang jay-zhuang marked this pull request as ready for review August 26, 2021 00:21
Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

LGTM!

start_str = Key(120);
start = start_str;
comp_num = my_cs->GetCompactionNum();
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), &start, nullptr));
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 expect some stat to have increased on primary side , like COMPACTION_BYTES_READ?

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 added check for statistics->getTickerCount(COMPACTION_KEY_DROP_NEWER_ENTRY), which shows the updated keys.
Not sure how we could check COMPACTION_BYTES_READ, seems we need to do GetThreadList() and check?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks. COMPACTION_BYTES_READ is also a stat you can get from statistics->getTickerCount().

Is this the fix?

  ASSERT_GE(primary_statistics->getTickerCount(COMPACTION_KEY_DROP_NEWER_ENTRY),
            primary_new_key);

If no compaction happened on the primary would that still pass because the ticker stat would equal primary_new_key?

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 mistake, it should ASSERT_GT not GE.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the confusion. COMPACT_READ_BYTES is the name of the ticker stat as we discussed.

Copy link
Contributor Author

@jay-zhuang jay-zhuang Sep 17, 2021

Choose a reason for hiding this comment

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

make sense.
But currently, we record the compact_read/write_bytes on both remote and local side (which should be fixed):
https://github.com/facebook/rocksdb/blob/9dd09dc4f302f2de5a2c34ab2cbc4c393b4503cc/db/compaction/compaction_job.cc#L1117-L1118
I think we did that at the beginning just to make sure with/without remote compaction it behaves exactly the same, which it's not necessary. I'll fix that and maybe add new metrics for remote compaction if we need record that.
On the other hand, I think because of the how the test CompactionService is implemented (which runs the remote compaction with the local compaction thread), the read/write bytes is still counted locally. I think we may need to update the test CompactionService, maybe to a separate process (ideally).
Anyway, I'm not going to fix it in this diff. Will follow up on that.

ROCKS_LOG_WARN(db_options_.info_log,
"[%s] [JOB %d] Remote compaction failed, status: %s",
compaction_input.column_family.name.c_str(), job_id_,
s.ToString().c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like tricky edge cases. If remote compaction returns kFailure and we can parse the compaction_result and it has compaction_result.status.ok(), then sub_compact->status will be OK. Is that right?

Logging s also could be confusing because it's the parsing status not the remote compaction status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that could happen, added log for such case.
And remove logging parsing status.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

LGTM. I think it's probably better to land now than to address my comment about the test.

start_str = Key(120);
start = start_str;
comp_num = my_cs->GetCompactionNum();
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), &start, nullptr));
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks. COMPACTION_BYTES_READ is also a stat you can get from statistics->getTickerCount().

Is this the fix?

  ASSERT_GE(primary_statistics->getTickerCount(COMPACTION_KEY_DROP_NEWER_ENTRY),
            primary_new_key);

If no compaction happened on the primary would that still pass because the ticker stat would equal primary_new_key?

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

Summary: Add support for fallback to local compaction, the user can
return `CompactionServiceJobStatus::kUseLocal` to instruct RocksDB to
run the compaction locally instead of waiting for the remote compaction
result.

Test Plan: unittest
@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@jay-zhuang merged this pull request in 1c290c7.

yoori pushed a commit to yoori/rocksdb that referenced this pull request Nov 26, 2023
Summary:
Add support for fallback to local compaction, the user can
return `CompactionServiceJobStatus::kUseLocal` to instruct RocksDB to
run the compaction locally instead of waiting for the remote compaction
result.

Pull Request resolved: facebook/rocksdb#8709

Test Plan: unittest

Reviewed By: ajkr

Differential Revision: D30560163

Pulled By: jay-zhuang

fbshipit-source-id: 65d8905a4a1bc185a68daa120997f21d3198dbe1
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

3 participants