-
Notifications
You must be signed in to change notification settings - Fork 84
merge recovery: optimization: use copy-iterator & server-send for small/medium keys #678
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e05a7c
binding: python: added server_send & start_copy_iterator session methods
abudnik 79da014
server-send: partially init iterator response before calling eblob_lo…
abudnik a66cfd1
tests: recovery: check that merge recovery removes moved keys from th…
abudnik 21e1e70
merge recovery: optimization: use copy-iterator & server-send for sma…
abudnik f7bd8c5
recovery: Iterator class refactoring
abudnik 755bedf
recovery: added description of ServerSendRecovery class & its methods
abudnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,7 +239,7 @@ def __init__(self, node, group, separately=False, trace_id=0): | |
| self.session.trace_id = trace_id | ||
| self.separately = separately | ||
|
|
||
| def get_key_range_id(self, key): | ||
| def _get_key_range_id(self, key): | ||
| if not self.separately: | ||
| return 0 | ||
|
|
||
|
|
@@ -260,7 +260,6 @@ def get_key_range_id(self, key): | |
|
|
||
| def start(self, | ||
| eid=IdRange.ID_MIN, | ||
| itype=elliptics.iterator_types.network, | ||
| flags=elliptics.iterator_flags.key_range | elliptics.iterator_flags.ts_range, | ||
| key_ranges=(IdRange(IdRange.ID_MIN, IdRange.ID_MAX),), | ||
| timestamp_range=(Time.time_min().to_etime(), Time.time_max().to_etime()), | ||
|
|
@@ -270,7 +269,6 @@ def start(self, | |
| group_id=0, | ||
| leave_file=False, | ||
| batch_size=1024): | ||
| assert itype == elliptics.iterator_types.network, "Only network iterator is supported for now" | ||
| assert flags & elliptics.iterator_flags.data == 0, "Only metadata iterator is supported for now" | ||
| assert len(key_ranges) > 0, "There should be at least one iteration range." | ||
| self.ranges = key_ranges | ||
|
|
@@ -300,12 +298,11 @@ def start(self, | |
| leave_file=leave_file) | ||
|
|
||
| ranges = [IdRange.elliptics_range(start, stop) for start, stop in key_ranges] | ||
| records = self.session.start_iterator(eid, | ||
| ranges, | ||
| itype, | ||
| flags, | ||
| timestamp_range[0], | ||
| timestamp_range[1]) | ||
| records = self._start_iterator(eid, | ||
| ranges, | ||
| flags, | ||
| timestamp_range) | ||
|
|
||
| iterated_keys = 0 | ||
| total_keys = 0 | ||
|
|
||
|
|
@@ -322,9 +319,8 @@ def start(self, | |
|
|
||
| if iterated_keys % batch_size == 0: | ||
| yield (iterated_keys, total_keys, start, end) | ||
| if record.response.status != 0: | ||
| continue | ||
| results[self.get_key_range_id(record.response.key)].append(record) | ||
|
|
||
| self._on_key_response(results, record) | ||
| end = time.time() | ||
|
|
||
| elapsed_time = records.elapsed_time() | ||
|
|
@@ -339,23 +335,34 @@ def start(self, | |
| .format(address, backend_id, repr(e), traceback.format_exc())) | ||
| yield None | ||
|
|
||
| @classmethod | ||
| def iterate_with_stats(cls, node, eid, timestamp_range, | ||
| def _start_iterator(self, eid, ranges, flags, timestamp_range): | ||
| return self.session.start_iterator(eid, | ||
| ranges, | ||
| elliptics.iterator_types.network, | ||
| flags, | ||
| timestamp_range[0], | ||
| timestamp_range[1]) | ||
|
|
||
| def _on_key_response(self, results, record): | ||
| if record.response.status == 0: | ||
| self._save_record(results, record) | ||
|
|
||
| def _save_record(self, results, record): | ||
| results[self._get_key_range_id(record.response.key)].append(record) | ||
|
|
||
| def iterate_with_stats(self, eid, timestamp_range, | ||
| key_ranges, tmp_dir, address, group_id, backend_id, batch_size, | ||
| stats, flags, leave_file=False, | ||
| separately=False, trace_id=0): | ||
| iterator = cls(node, group_id, separately, trace_id=trace_id) | ||
| result = iterator.start(eid=eid, | ||
| timestamp_range=timestamp_range, | ||
| flags=flags, | ||
| key_ranges=key_ranges, | ||
| tmp_dir=tmp_dir, | ||
| address=address, | ||
| backend_id=backend_id, | ||
| group_id=group_id, | ||
| batch_size=batch_size, | ||
| leave_file=leave_file, | ||
| ) | ||
| stats, flags, leave_file=False): | ||
| result = self.start(eid=eid, | ||
| flags=flags, | ||
| key_ranges=key_ranges, | ||
| timestamp_range=timestamp_range, | ||
| tmp_dir=tmp_dir, | ||
| address=address, | ||
| backend_id=backend_id, | ||
| group_id=group_id, | ||
| leave_file=leave_file, | ||
| batch_size=batch_size,) | ||
| result_len = 0 | ||
| for it in result: | ||
| if it is None: | ||
|
|
@@ -379,6 +386,24 @@ def iterate_with_stats(cls, node, eid, timestamp_range, | |
| return result, result_len | ||
|
|
||
|
|
||
| class MergeRecoveryIterator(Iterator): | ||
| ''' | ||
| This class is used in merge recovery for backend iteratation on ranges which are not belong to | ||
| it using copy iterator. Every iterated key is moved to the backend, where it should exists. | ||
| If moving of some key was failed, then it saves the key to the results container. | ||
| ''' | ||
| def __init__(self, *args, **kwargs): | ||
| super(MergeRecoveryIterator, self).__init__(*args, **kwargs) | ||
|
|
||
| def _start_iterator(self, eid, ranges, flags, timestamp_range): | ||
| flags |= elliptics.iterator_flags.move | ||
| return self.session.start_copy_iterator(eid, ranges, [eid.group_id], flags, timestamp_range[0], timestamp_range[1]) | ||
|
|
||
| def _on_key_response(self, results, record): | ||
| if record.response.status != 0: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should also update statistics in own way, because now it will not show any recovering progress and all iterator's statistics will be about keys which weren't recovered by copy-iterator. |
||
| self._save_record(results, record) | ||
|
|
||
|
|
||
| class MergeData(object): | ||
| """ | ||
| Assist class for IteratorResult.__merge__ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the destination groups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CopyIterator is used in merge recovery only, that's why exactly one group specified here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CopyIteratorname implies the opposite, please add documentation describing how it is used and better change the nameThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abudnik@f7bd8c5