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

INDY-1386: clear requests list after view change for ordered txns #781

Merged

Conversation

Toktar
Copy link
Contributor

@Toktar Toktar commented Jun 29, 2018

Changes:

  • add tests in test_different_last_ordered_before_view_change.py,
  • clear requests after view change for ordered txns,
  • change last ordered after view change to maximum of ordered on master and current value.

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>
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
Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved.

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
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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] \
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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).

Copy link
Contributor Author

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).

Copy link
Contributor Author

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):
Copy link
Contributor

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.

Copy link
Contributor Author

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


Copy link
Contributor

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

Copy link
Contributor Author

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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>
@@ -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:
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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)

pp_seq_no)
if not resp:
if not (validReqs or inValidReqs):
Copy link
Contributor

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)

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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],
Copy link
Contributor

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

Copy link
Contributor Author

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>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@Toktar
Copy link
Contributor Author

Toktar commented Jul 4, 2018

test this please

…ests()

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@ashcherbakov ashcherbakov merged commit 6846b63 into hyperledger:master Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants