-
Notifications
You must be signed in to change notification settings - Fork 377
INDY-1545: stop processing checkpoints in view change #854
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
ashcherbakov
merged 8 commits into
hyperledger:master
from
Toktar:bugfix-1545-checkponts-cleaning-preprepares
Aug 8, 2018
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d40fbeb
INDY-1545: add test for detect correct checkpoint cleaning
Toktar b17f68d
INDY-1545: add bugfix for checkpoint cleaning
Toktar 707968f
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar e5c3be7
INDY-1545: refactoring test test_checkpoints_removal_in_view_change.py
Toktar 33b5622
INDY-1545: update checks test_checkpoints_removal_in_view_change
Toktar 6d43c48
INDY-1545: stop checkpoint processing in view change
Toktar e326e76
INDY-1545: revert logic of chooses view in markCheckPointStable
Toktar eef5bc6
INDY-1545: add check that checkpoints don't processing in view change
Toktar 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
119 changes: 119 additions & 0 deletions
119
plenum/test/checkpoints/test_checkpoints_removal_in_view_change.py
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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
from numbers import Rational | ||
|
||
import math | ||
import pytest | ||
import sys | ||
|
||
from plenum.common.constants import CHECKPOINT, COMMIT | ||
from plenum.test.delayers import cDelay, chk_delay, lsDelay, vcd_delay | ||
from plenum.test.helper import sdk_send_random_requests, \ | ||
sdk_get_and_check_replies, sdk_send_random_and_check | ||
from plenum.test.node_catchup.helper import ensure_all_nodes_have_same_data | ||
from plenum.test.test_node import ensureElectionsDone | ||
from stp_core.loop.eventually import eventually | ||
|
||
CHK_FREQ = 2 | ||
|
||
|
||
def test_checkpoints_removed_in_view_change(chkFreqPatched, | ||
txnPoolNodeSet, | ||
looper, | ||
sdk_pool_handle, | ||
sdk_wallet_client): | ||
''' | ||
Check that checkpoint finalize in view change before catchup doesn't clean | ||
necessary data from requests and 3pc queues. | ||
''' | ||
slow_nodes = txnPoolNodeSet[:3] | ||
fast_nodes = txnPoolNodeSet[3:] | ||
# delay checkpoints processing for slow_nodes | ||
delay_msg(slow_nodes, chk_delay) | ||
# send txns for finalizing current checkpoint | ||
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, | ||
sdk_wallet_client, CHK_FREQ) | ||
ensure_all_nodes_have_same_data(looper, nodes=txnPoolNodeSet) | ||
# delay commits processing for slow_nodes | ||
delay_msg(slow_nodes, cDelay) | ||
|
||
requests = sdk_send_random_requests(looper, sdk_pool_handle, | ||
sdk_wallet_client, 1) | ||
# check that slow nodes have prepared certificate with new txn | ||
looper.run(eventually(last_prepared_certificate, | ||
slow_nodes, | ||
(0, CHK_FREQ + 1))) | ||
# check that fast_nodes ordered new txn | ||
looper.run(eventually(last_ordered_check, | ||
fast_nodes, | ||
(0, CHK_FREQ + 1))) | ||
# check that fast_nodes finalized first checkpoint and slow_nodes are not | ||
looper.run(eventually(check_checkpoint_finalize, | ||
fast_nodes, | ||
1, CHK_FREQ)) | ||
for n in slow_nodes: | ||
assert not n.master_replica.checkpoints[(1, CHK_FREQ)].isStable | ||
|
||
# View change start emulation for change viewNo and fix last prepare | ||
# certificate, because if we start a real view change then checkpoints will | ||
# clean and the first checkpoint would not be need in finalizing. | ||
for node in txnPoolNodeSet: | ||
node.viewNo += 1 | ||
node.master_replica.on_view_change_start() | ||
|
||
# reset delay for checkpoints | ||
reset_delay(slow_nodes, CHECKPOINT) | ||
# reset view change emulation and start real view change for finish it in | ||
# a normal mode with catchup | ||
for node in txnPoolNodeSet: | ||
node.viewNo -= 1 | ||
node.view_changer.on_master_degradation() | ||
for n in slow_nodes: | ||
assert not n.master_replica.checkpoints[(1, CHK_FREQ)].isStable | ||
# Check ordering the last txn before catchup. Check client reply is enough | ||
# because slow_nodes contains 3 nodes and without their replies sdk method | ||
# for get reply will not successfully finish. | ||
reset_delay(slow_nodes, COMMIT) | ||
sdk_get_and_check_replies(looper, requests) | ||
looper.run(eventually(last_ordered_check, | ||
txnPoolNodeSet, | ||
(0, CHK_FREQ + 1))) | ||
# check view change finish and checkpoints were cleaned | ||
ensureElectionsDone(looper, txnPoolNodeSet) | ||
for n in slow_nodes: | ||
assert (1, CHK_FREQ) not in n.master_replica.checkpoints | ||
# check that all nodes have same data after new txns ordering | ||
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, | ||
sdk_wallet_client, CHK_FREQ) | ||
ensure_all_nodes_have_same_data(looper, nodes=txnPoolNodeSet) | ||
|
||
|
||
def delay_msg(nodes, delay_function, types=None): | ||
for n in nodes: | ||
if types is None: | ||
n.nodeIbStasher.delay(delay_function(sys.maxsize)) | ||
else: | ||
n.nodeIbStasher.delay(delay_function(sys.maxsize, types)) | ||
|
||
|
||
def reset_delay(nodes, message): | ||
for n in nodes: | ||
n.nodeIbStasher.reset_delays_and_process_delayeds(message) | ||
|
||
|
||
def last_prepared_certificate(nodes, num): | ||
for n in nodes: | ||
assert n.master_replica.last_prepared_certificate_in_view() == num | ||
|
||
|
||
def check_checkpoint_finalize(nodes, start_pp_seq_no, end_pp_seq_no): | ||
for n in nodes: | ||
checkpoint = n.master_replica.checkpoints[(start_pp_seq_no, end_pp_seq_no)] | ||
assert checkpoint.isStable | ||
|
||
|
||
def last_ordered_check(nodes, last_ordered, instance_id=None): | ||
for n in nodes: | ||
last_ordered_3pc = n.master_last_ordered_3PC \ | ||
if instance_id is None \ | ||
else n.replicas[instance_id].last_ordered_3pc | ||
assert last_ordered_3pc == last_ordered | ||
|
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.
Why do we have a check
self.isPrimary is None
?