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

HDDS-1986. Fix listkeys API. #1588

Merged
merged 4 commits into from
Oct 10, 2019
Merged

Conversation

bharatviswa504
Copy link
Contributor

Implement listKeys API.

@smengcl
Copy link
Contributor

smengcl commented Oct 3, 2019

/label ozone

// of maxKeys from the sorted map.
currentCount = 0;

for (Map.Entry<String, OmKeyInfo> cacheKey : cacheKeyMap.entrySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The second iteration is unfortunate. We should see if there is a way to avoid it.

}

@Test
public void testListKeysWithFewDeleteEntriesInCache() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

How are you ensuring entries are in the cache? For that you have to pause double buffer flush right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this test case, we are adding entries in cache manually. It is not an integration test.

Copy link
Contributor

@arp7 arp7 left a comment

Choose a reason for hiding this comment

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

The change looks okay. I am worried about the potential performance of listKeys though. I am okay to let this go in for now since it fixes a correctness issue. However we will need to measure & fix list performance at some point.

List<OmKeyInfo> result = new ArrayList<>();
if (maxKeys == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

or <= 0 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that would be a nice bit of defensive programming. Let's make the check <= 0.

// and construct treeMap which match with keyPrefix and are greater than or
// equal to startKey. Later we can revisit this, if list operation
// is becoming slow.
while (iterator.hasNext()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How many keys are expected in this cache? and how many in the tree ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel that we are better off leaving the old code in place...where we can read from the DB.. Worst, we might have to make sure that cache is flushed to DB before doing the list operation.But practically it may not matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am ok with putting this change in if we can prove that we can do large list keys. You might want to borrow the DB from @nandakumar131 and see if you can list keys with this patch, just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key cache is not full cache, so if double buffer flush is going on well in background, this should have around couple of 100 entries. When I started freon with 10 threads, i see the value of maximum iteration is 200. So, almost in the cache we have 200 entries. (But on tried with busy workload clusters, slow disks)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With current new code when the list happens we should consider entries from buffer and DB. (As we return the response to end-user after adding entries to cache). So, if user does list as next operation(next to create bucket) the bucket might/might not be there until double buffer flushes. As until double buffer flushes, we will have entries in cache. (This will not be problem for non-HA, as we return the response, only after the flush)

Copy link
Contributor

@arp7 arp7 left a comment

Choose a reason for hiding this comment

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

+1

I am okay to get this committed with a minor comment below, assuming there are no unaddressed comments from @anuengineer.

We should benchmark list operations later in case any further optimization is needed.

@bharatviswa504
Copy link
Contributor Author

Addressed the review comment.

@bharatviswa504
Copy link
Contributor Author

+1

I am okay to get this committed with a minor comment below, assuming there are no unaddressed comments from @anuengineer.

We should benchmark list operations later in case any further optimization is needed.

I will run the benchmarks once after the list Operations is fixed.

@anuengineer
Copy link
Contributor

Let us get this in, I expect some of these things we will learn the right choices only when we really benchmark and test. The sad this is that some of these changes can make our system unstable.
FYI: @elek , I know that you might not be happy with this approach. But it is hard to judge the impact of these change till we have this code in and start testing.

@bharatviswa504
Copy link
Contributor Author

Thank You @arp7 and @anuengineer for the review.
I will try to run the benchmark and update it.

Copy link
Contributor

@nandakumar131 nandakumar131 left a comment

Choose a reason for hiding this comment

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

Overall the patch looks ok.
We should definitely try to optimise the listKeys call.

Copy link
Contributor

@nandakumar131 nandakumar131 left a comment

Choose a reason for hiding this comment

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

Thanks @bharatviswa504 for working on this, overall the change looks ok.

@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@apache apache deleted a comment from hadoop-yetus Oct 10, 2019
@bharatviswa504 bharatviswa504 merged commit 9c72bf4 into apache:trunk Oct 10, 2019
@bharatviswa504
Copy link
Contributor Author

Thank You all for the review.
I have committed this to the trunk.

amahussein pushed a commit to amahussein/hadoop that referenced this pull request Oct 29, 2019
RogPodge pushed a commit to RogPodge/hadoop that referenced this pull request Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants