Skip to content

Update Flush policy in PartitionedIndexBuilder on switching from user-key to internal-key mode - #7022

Closed
akankshamahajan15 wants to merge 1 commit into
meta:masterfrom
akankshamahajan15:partitioned_index_bug
Closed

akankshamahajan15 wants to merge 1 commit into
meta:masterfrom
akankshamahajan15:partitioned_index_bug

Conversation

@akankshamahajan15

Copy link
Copy Markdown
Contributor

Summary: When format_version is high enough to support user-key and there are index entries for same user key that spans multiple data blocks then it changes from user-key mode to internal-key mode. But the flush policy is not reset to point to Block Builder of internal-keys. After this switch, no entries are added to user key index partition result, thus it never triggers flushing the block.

Fix: After adding the entry in sub_builder_index_, if there is a switch from user-key to internal-key, then flush policy is updated to point to Block Builder of internal-keys index partition.

Test Plan: 1. make check -j64
2. Added one unit test case

Reviewers:

Subscribers:

Tasks: T68809728

Tags:

@akankshamahajan15
akankshamahajan15 requested a review from ajkr June 23, 2020 22:59

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

1 similar comment
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread db/db_test2.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice test!

Comment thread table/block_based/index_builder.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an allocation per index entry which might be nontrivial. I think the easy way to avoid these extra allocations is to reset the flush policy only when !seperator_is_key_plus_seq_.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Initially I added the check but then number of partitions got changed (it was changed from 11 to 2). So I couldn't understand why the value got changed by adding additional check !seperator_is_key_plus_seq_.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see you added it back. Does it behave as expected now (produce partitions around metadata_block_size bytes) or is there still an unexpectedly small number of partitions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh my bad. The check at line 132 is fine so i added that but by adding check here (line 170) partitions are still 2 (I forgot to remove this check while uploading the diff). I am still not sure why this is the case. I have added logs to look further for debugging.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

discussed offline, seems it is producing the expected number of partitions now.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@ajkr ajkr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks very much for fixing this!

Comment thread table/block_based/index_builder.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

discussed offline, seems it is producing the expected number of partitions now.

Comment thread HISTORY.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For release note it's nice to describe in terms of affected user APIs / options, so people can quickly check whether they're affected (in this case the affected option is index_type == kTwoLevelIndexSearch)

…-key to internal-key mode

Summary: When format_version is high enough to support user-key and there are index entries for same user key that spans multiple data blocks then it changes from user-key mode to internal-key mode. But the flush policy is not reset to point to Block Builder of internal-keys. After this switch, no entries are added to user key index partition result, thus it never triggers flushing the block.

Fix: After adding the entry in sub_builder_index_, if there is a switch from user-key to internal-key, then flush policy is updated to point to Block Builder of internal-keys index partition.

Test Plan: 1. make check -j64
           2. Added one unit test case

Reviewers:

Subscribers:

Tasks: T68809728

Tags:
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@akankshamahajan15 merged this pull request in 5edfe3a.

pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Jul 2, 2020
…rom user-key to internal-key mode (meta#7022)"

This reverts commit 5edfe3a.
facebook-github-bot pushed a commit that referenced this pull request Jul 2, 2020
Summary:
Even though local bisection gave me a clear signal (and still does) that reverting #7049 would fix the failures in MultiThreadedDBTest, #7022 seems to be the root cause. Reverting #7022 and keeping #7049 seems to fix the issue in local reproducer also. (Had these landed in opposite order, bisection would have found the root cause.)
Pull Request resolved: #7071

Reviewed By: akankshamahajan15

Differential Revision: D22362857

Pulled By: pdillinger

fbshipit-source-id: ed63df3d74e9d4ce1604de8fe43b216166c7a3f0
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
…-key to internal-key mode (meta#7022)

Summary:
When format_version is high enough to support user-key and there are index entries for same user key that spans multiple data blocks then it changes from user-key mode to internal-key mode. But the flush policy is not reset to point to Block Builder of internal-keys. After this switch, no entries are added to user key index partition result, thus it never triggers flushing the block.

Fix: After adding the entry in sub_builder_index_, if there is a switch from user-key to internal-key, then flush policy is updated to point to Block Builder of internal-keys index partition.
Pull Request resolved: meta#7022

Test Plan:
1. make check -j64
           2. Added one unit test case

Reviewed By: ajkr

Differential Revision: D22197734

Pulled By: akankshamahajan15

fbshipit-source-id: d87e9e46bccab8e896ee6979d6b79c51f73d479e
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
Even though local bisection gave me a clear signal (and still does) that reverting meta#7049 would fix the failures in MultiThreadedDBTest, meta#7022 seems to be the root cause. Reverting meta#7022 and keeping meta#7049 seems to fix the issue in local reproducer also. (Had these landed in opposite order, bisection would have found the root cause.)
Pull Request resolved: meta#7071

Reviewed By: akankshamahajan15

Differential Revision: D22362857

Pulled By: pdillinger

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