-
Notifications
You must be signed in to change notification settings - Fork 366
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
INDY-1386: clear requests list after view change for ordered txns #781
INDY-1386: clear requests list after view change for ordered txns #781
Conversation
Changes: - add test ordering on master with view change. - add test ordering on backup with view change. Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Changes: - add test test_different_prepares_on_backup_before_view_change - clear requests after view change - change last ordered to max ordered after view change Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
plenum/server/replica.py
Outdated
master_last_ordered_3pc = self.node.master_replica.last_ordered_3pc | ||
if master_last_ordered_3pc[0] >= self.last_ordered_3pc[0] \ | ||
and master_last_ordered_3pc[1] > self.last_ordered_3pc[1]: | ||
self.last_ordered_3pc = master_last_ordered_3pc |
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.
We store here the value of the tuple, without the risk of passing the reference, is it?
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@@ -530,6 +530,8 @@ def startViewChange(self, proposed_view_no: int): | |||
|
|||
self.node.on_view_change_start() | |||
self.node.start_catchup() | |||
for replica in self.node.replicas: |
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.
Should we do it when we finished view changed?
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.
Moved.
plenum/server/replica.py
Outdated
master_last_ordered_3pc = self.node.master_replica.last_ordered_3pc | ||
if master_last_ordered_3pc[0] >= self.last_ordered_3pc[0] \ | ||
and master_last_ordered_3pc[1] > self.last_ordered_3pc[1]: | ||
self.last_ordered_3pc = master_last_ordered_3pc |
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.
Do we need to set last_ordered_3pc
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.
We can to do it in other place. Where will it be better?
plenum/server/replica.py
Outdated
self.requests.free(key) | ||
self.requestQueues[int(ledger_id)].discard(key) | ||
master_last_ordered_3pc = self.node.master_replica.last_ordered_3pc | ||
if master_last_ordered_3pc[0] >= self.last_ordered_3pc[0] \ |
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.
Please use compare_3PC_keys
for comparison
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.
Done.
fast_nodes, | ||
(old_view_no, old_last_ordered[1] + 1), | ||
slow_instance)) | ||
last_ordered_for_slow = slow_nodes[0].replicas[slow_instance].last_ordered_3pc |
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.
Please also check that last_ordered
on slow nodes (on slow instance) is (old_view_no, old_last_ordered).
Please check that last_ordered
on all master instances is (old_view_no, old_last_ordered+1).
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.
On backup instances last ordered is (new_view_no, 1) because with current logic we sending preprepare message without transactions. And order it. I think it's a very strange behavior. But for backup, may be it is normal.
Added check that last_ordered on all master instances is (old_view_no, old_last_ordered+1).
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.
Need to add a check of empty transaction list for sending preprepare?
assert node.replicas[instId].last_ordered_3pc == last_ordered | ||
|
||
|
||
def view_change_done(nodes: [Node], view_no): |
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.
This doesn't indicate end of view change, rather the beginning.
Please call ensureElectionsDone
in addition to make sure that it's finished.
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.
Done.
from plenum.test.stasher import delay_rules | ||
from stp_core.loop.eventually import eventually | ||
|
||
|
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.
Please add tests that make sure we don't request any Propagates after View Change if one of the replicas on backup instance ordered less than others, and it becomes a Primary
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.
Added check that no one propagate request wasn't sent.
node.view_changer.on_master_degradation() | ||
|
||
# wait for view change done on all nodes | ||
looper.run(eventually(view_change_done, txnPoolNodeSet, old_view_no + 1)) |
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.
This doesn't indicate end of view change, rather the beginning.
Please call ensureElectionsDone in addition to make sure that it's finished.
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.
Done.
Changes: - update test_different_prepares_on_backup_before_view_change - move requests cleaning after view change Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Changes: - added check in test_different_last_ordered_on_backup_before_view_change for last_order on master instance. Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
plenum/server/node.py
Outdated
@@ -596,6 +596,8 @@ def on_view_change_complete(self): | |||
if self.view_changer.propagate_primary: # TODO VCH | |||
self.master_replica.on_propagate_primary_done() | |||
self.view_changer.last_completed_view_no = self.view_changer.view_no | |||
for replica in self.replicas: |
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.
Please add a comment on why we do it
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.
Should we describe the case with propagates or commented what we do?
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.
Yes, please describe the case with propagates (a reference to the tests would also be useful)
plenum/server/replica.py
Outdated
pp_seq_no) | ||
if not resp: | ||
if not (validReqs or inValidReqs): |
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.
Please add a unit test for this (see test/replica/test_api
)
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.
Are we need to check that create3PCBatch() doesn't return value or log message too (and change logLevel )?
from stp_core.loop.eventually import eventually | ||
|
||
|
||
def test_different_last_ordered_on_backup_before_view_change(looper, txnPoolNodeSet, |
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 would rename the tests to test_no_propagate_request_on_different_last_ordered_on_backup_before_vc
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.
done
for node in txnPoolNodeSet) | ||
|
||
|
||
def test_different_prepares_on_backup_before_view_change(looper, txnPoolNodeSet, |
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 would rename the tests to test_no_propagate_request_on_different_prepares_on_backup_before_vc
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.
done
for node in txnPoolNodeSet) | ||
|
||
|
||
def test_different_last_ordered_on_master_before_view_change(looper, txnPoolNodeSet, |
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 would rename the tests to test_no_propagate_request_on_different_last_ordered_on_master_before_vc
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.
done
(node.viewNo, ppSeqNo) in replica.sentPrePrepares | ||
|
||
|
||
def last_ordered(nodes: [Node], |
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.
Please rename to check_last_ordered
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.
done
…_before_vc.py Changes: - update test_no_propagate_request_on_different_last_ordered_before_vc.py - added unit test_create_3pc_batch_with_empty_requests Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
…nto task-1386-limit-propagate-request
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
…nto task-1386-limit-propagate-request
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
test this please |
…ests() Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Changes: