- Notifications
You must be signed in to change notification settings - Fork 55
utubettl: remove unnecessary on_task_change call #97
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
Closed
Closed
Changes from 1 commit
Commits
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
utubettl: if the task being deleted was not taken, do not wake neighb…
…our task
- Loading branch information
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -290,27 +290,24 @@ function method.take(self) | |
| end | ||
| end | ||
| | ||
| local function process_neighbour(self, task, operation) | ||
| self:on_task_change(task, operation) | ||
| if task ~= nil then | ||
| local neighbour = self.space.index.utube:min{state.READY, task[i_utube]} | ||
| if neighbour ~= nil | ||
| and neighbour[i_utube] == task[i_utube] | ||
| and neighbour[i_status] == state.READY | ||
| then | ||
| self:on_task_change(neighbour) | ||
| end | ||
| local function wake_neighbour(self, utube) | ||
| local neighbour = self.space.index.utube:select({state.READY, utube}, {limit=1})[1] | ||
| if neighbour ~= nil then | ||
| self:on_task_change(neighbour) | ||
| end | ||
| return task | ||
| end | ||
| | ||
| -- delete task | ||
| function method.delete(self, id) | ||
| local task = self.space:get(id) | ||
| self.space:delete(id) | ||
| if task ~= nil then | ||
| self.space:delete(id) | ||
| if task[i_status] == state.TAKEN then | ||
| wake_neighbour(self, task[i_utube]) | ||
| end | ||
| ||
| task = task:transform(i_status, 1, state.DONE) | ||
| return process_neighbour(self, task, 'delete') | ||
| self:on_task_change(task, 'delete') | ||
LeonidVas marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| return task | ||
| end | ||
| self:on_task_change(task, 'delete') | ||
| end | ||
| | @@ -327,9 +324,9 @@ function method.release(self, id, opts) | |
| { '=', i_next_event, event_time(opts.delay) }, | ||
| { '+', i_ttl, time(opts.delay) } | ||
| }) | ||
| if task ~= nil then | ||
| return process_neighbour(self, task, 'release') | ||
| end | ||
| self:on_task_change(task, 'release') | ||
LeonidVas marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| wake_neighbour(self, task[i_utube]) | ||
| return task | ||
| else | ||
| task = self.space:update(id, { | ||
| { '=', i_status, state.READY }, | ||
| | @@ -344,9 +341,10 @@ end | |
| function method.bury(self, id) | ||
| local task = self.space:update(id, {{ '=', i_status, state.BURIED }}) | ||
| if task ~= nil then | ||
| return process_neighbour( | ||
| self, task:transform(i_status, 1, state.BURIED), 'bury' | ||
| ) | ||
| wake_neighbour(self, task[i_utube]) | ||
| task = task:transform(i_status, 1, state.BURIED) | ||
LeonidVas marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| self:on_task_change(task, 'bury') | ||
| return task | ||
| end | ||
| self:on_task_change(task, 'bury') | ||
| end | ||
| | ||
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.
I think using min() with checks is more correct (with link to tarantool/tarantool#3167)
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.
aren't they equivalent?
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.
I meant that the behavior of max() was different from expected and I see no reason to replace min() to select(). I agree with you that the default iterator is ALL(same as GE) and the results will be equivalent. But generally min () is used in utubettl driver and IMHO: it better reflects the idea. I may be wrong. What is the reason for choosing select()?
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.
from the 1.10 docs:
so we cannot be sure that
neighbourwill be from the same utube on tarantool 1.10There 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.
Hmm, as I understand you say about tarantool/tarantool@8bbd4a6 . Looks like you're right! Please add a comment. If you add a test, it will be great!
Uh oh!
There was an error while loading. Please reload this page.
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.
The default iterator is 'EQ'.