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

Fix Get() return status when block cache is disabled #8485

Closed
wants to merge 4 commits into from

Conversation

hongrubb
Copy link
Contributor

@hongrubb hongrubb commented Jul 6, 2021

This PR is for #8453

We need to update s = biter.status(); when biter.status().IsIncomplete() is true. By doing this, can fix the problem in issue.
Besides, we still need to update db_statistics in get_context.ReportCounters() before return back.

@facebook-github-bot
Copy link
Contributor

@ajkr 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.

Thanks for finding/fixing the problem! This feels like something that's reasonably straightforward to cover in a test case, if you have time.

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.

Also do you mind updating HISTORY.md with a "Bug Fixes" item for preventing empty value returned for non-existent key, and a separate item for fixing dropped stat block cache counter updates for failed queries?

@@ -1938,16 +1938,16 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
PERF_COUNTER_BY_LEVEL_ADD(get_from_table_nanos, timer.ElapsedNanos(),
fp.GetHitFileLevel());
}
if (!status->ok()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually is it better to call ReportCounters() in this old !status->ok() conditional body? Seems like they are supposed to be updated before return as long as db_statistics_ != nullptr.

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 don't know if I understand you correctly.
You mean the code should look like this?

    if (!status->ok()) {
      if (db_statistics_ != nullptr) {
        get_context.ReportCounters();
      }
      return;
    }

If that, I will change the code soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right.

@hongrubb
Copy link
Contributor Author

hongrubb commented Jul 8, 2021

Thanks for finding/fixing the problem! This feels like something that's reasonably straightforward to cover in a test case, if you have time.

Sorry, I don't have time to add test cases right now. But I'd like to contribute test cases in later weeks. Is it ok to submit another PR for test cases?

@hongrubb
Copy link
Contributor Author

hongrubb commented Jul 8, 2021

Also do you mind updating HISTORY.md with a "Bug Fixes" item for preventing empty value returned for non-existent key, and a separate item for fixing dropped stat block cache counter updates for failed queries?

I'd like to do that, I will update it soon.

@ajkr
Copy link
Contributor

ajkr commented Jul 8, 2021

Thanks for finding/fixing the problem! This feels like something that's reasonably straightforward to cover in a test case, if you have time.

Sorry, I don't have time to add test cases right now. But I'd like to contribute test cases in later weeks. Is it ok to submit another PR for test cases?

Sure, sounds good.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

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.

Looks great, thank you very much!

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@ajkr
Copy link
Contributor

ajkr commented Jul 12, 2021

Do you mind checking this test?

stdout: Note: Google Test filter = DBBlockCacheTest.TestWithCompressedBlockCache
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from DBBlockCacheTest
[ RUN      ] DBBlockCacheTest.TestWithCompressedBlockCache
internal_repo_rocksdb/repo/db/db_block_cache_test.cc:99: Failure
Expected equality of these values:
  miss_count_ + expected_misses
    Which is: 9
  new_miss_count
    Which is: 10
internal_repo_rocksdb/repo/db/db_block_cache_test.cc:99: Failure
Expected equality of these values:
  miss_count_ + expected_misses
    Which is: 10
  new_miss_count

This is from our internal pre-land test run; I don't see the error in any test run here somehow...

@hongrubb
Copy link
Contributor Author

Do you mind checking this test?

stdout: Note: Google Test filter = DBBlockCacheTest.TestWithCompressedBlockCache
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from DBBlockCacheTest
[ RUN      ] DBBlockCacheTest.TestWithCompressedBlockCache
internal_repo_rocksdb/repo/db/db_block_cache_test.cc:99: Failure
Expected equality of these values:
  miss_count_ + expected_misses
    Which is: 9
  new_miss_count
    Which is: 10
internal_repo_rocksdb/repo/db/db_block_cache_test.cc:99: Failure
Expected equality of these values:
  miss_count_ + expected_misses
    Which is: 10
  new_miss_count

This is from our internal pre-land test run; I don't see the error in any test run here somehow...

Sure.

@hongrubb
Copy link
Contributor Author

hongrubb commented Jul 13, 2021

@ajkr Hi, I think I have found the problem. It's very interesting!

I found the failed test was added by #8242 25days ago.
The test failed at CheckCacheCounters(), but I think we should update the counter even though the Get() is failed.

  ASSERT_EQ("Result incomplete: Insert failed due to LRU cache being full.",
            Get(ToString(kNumBlocks - 1)));
  // Failure won't record the miss counter.
  CheckCacheCounters(options, 0, 0, 0, 1);

@akankshamahajan15 thanks for the test and detailed comment in code, it helped me a lot. And please take a look at this problem, maybe we should change this test.

@akankshamahajan15
Copy link
Contributor

The test failed at CheckCacheCounters(), but I think we should update the counter even though the Get() is failed.

  ASSERT_EQ("Result incomplete: Insert failed due to LRU cache being full.",
            Get(ToString(kNumBlocks - 1)));
  // Failure won't record the miss counter.
  CheckCacheCounters(options, 0, 0, 0, 1);

@akankshamahajan15 thanks for the test and detailed comment in code, it helped me a lot. And please take a look at this problem, maybe we should change this test.

Since you fixed the bug of adding statistics when query is failed", this test should be updated to take that into account. Please feel free to update the test. Thanks for fixing the bug.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@ajkr merged this pull request in 8700332.

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.

5 participants