From cdb55c5e870efeebd4761cdd25dc3b006eb6ebca Mon Sep 17 00:00:00 2001 From: Phil Mesnier Date: Wed, 20 Dec 2017 17:28:23 -0600 Subject: [PATCH] address an unfortunate side-effect of a notification storm that was caused by the fix for other sync issues. --- plugins/net_plugin/net_plugin.cpp | 14 +++- tests/p2p_tests/sync/message_storm.sh | 107 ++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100755 tests/p2p_tests/sync/message_storm.sh diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index eaf02fee0ea..aa821c169bc 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1232,6 +1232,7 @@ namespace eosio { } void sync_manager::start_sync( connection_ptr c, uint32_t target) { + #if 0 if( !syncing()) { sync_last_requested_num = chain_plug->chain().head_block_num(); fc_dlog(logger, "Inform other open connections that we are syncing"); @@ -1246,6 +1247,12 @@ namespace eosio { } } } + #endif + + if (!syncing()) { + fc_dlog( logger, "We are already caught up."); + return; + } ilog( "Catching up with chain, our last req is ${cc}, theirs is ${t} peer ${p}", ( "cc",sync_last_requested_num)("t",target)("p",c->peer_name())); if( target > sync_known_lib_num) { sync_known_lib_num = target; @@ -1547,8 +1554,9 @@ namespace eosio { //-------------------------------- // sync need checkz; // - // 0. my head block id == peer head id means we are all caugnt up block wize - // 1. my lib < peer lib - start sync locally + // -1. another connection has already decided we are synching so continue with this connection + // 0. my head block id == peer head id means we are all caugnt up block wise + // 1. my head block num < peer lib - start sync locally // 2. my lib > peer lib - send an last_irr_catch_up notice if not the first generation // // 3 my head block num <= peer head block num - update sync state and send a catchup request @@ -1611,7 +1619,7 @@ namespace eosio { c->syncing = true; return; } - elog ("sync check failed to resolbe status"); + elog ("sync check failed to resolve status"); return; #if 0 if( peer_lib > head || sync_master->syncing() ) { diff --git a/tests/p2p_tests/sync/message_storm.sh b/tests/p2p_tests/sync/message_storm.sh new file mode 100755 index 00000000000..dc7103aec97 --- /dev/null +++ b/tests/p2p_tests/sync/message_storm.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +############################################################### +# -p +# -n +# -s +# -d +############################################################### + +pnodes=21 +topo=mesh +delay=5 + +args=`getopt p:n:s:d: $*` +if [ $? == 0 ]; then + + set -- $args + for i; do + case "$i" + in + -p) pnodes=$2; + shift; shift;; + -n) total_nodes=$2; + shift; shift;; + -d) delay=$2; + shift; shift;; + -s) topo="$2"; + shift; shift;; + --) shift; + break;; + esac + done +else + echo "huh we got err $?" + if [ -n "$1" ]; then + pnodes=$1 + if [ -n "$2" ]; then + topo=$2 + if [ -n "$3" ]; then + total_nodes=$3 + fi + fi + fi +fi + +total_nodes="${total_nodes:-`echo $pnodes`}" + +rm -rf tn_data_* +if [ "$delay" == 0 ]; then + programs/launcher/launcher -p $pnodes -n $total_nodes -s $topo +else + programs/launcher/launcher -p $pnodes -n $total_nodes -s $topo -d $delay --eosd "--log-level-net-plugin debug" +fi + +sleep 7 +echo "start" > test.out +port=8888 +endport=`expr $port + $total_nodes` +echo endport = $endport +while [ $port -ne $endport ]; do + programs/eosc/eosc --port $port get block 1 >> test.out 2>&1; + port=`expr $port + 1` +done + +grep 'producer"' test.out | tee summary | sort -u -k2 | tee unique +prodsfound=`wc -l < unique` +lines=`wc -l < summary` +if [ $lines -eq $total_nodes -a $prodsfound -eq 1 ]; then + echo all synced +# programs/launcher/launcher -k 15 +# exit +fi +echo $lines reports out of $total_nodes and prods = $prodsfound +sleep 18 +programs/eosc/eosc --port 8888 get block 5 +sleep 15 +programs/eosc/eosc --port 8888 get block 10 +sleep 15 +programs/eosc/eosc --port 8888 get block 15 +sleep 15 +programs/eosc/eosc --port 8888 get block 20 +sleep 15 +echo "pass 2" > test.out +port=8888 +while [ $port -ne $endport ]; do + programs/eosc/eosc --port $port get block 1 >> test.out 2>&1; + port=`expr $port + 1` +done + + +grep 'producer"' test.out | tee summary | sort -u -k2 | tee unique +prodsfound=`wc -l < unique` +lines=`wc -l < summary` +if [ $lines -eq $total_nodes -a $prodsfound -eq 1 ]; then + echo all synced + programs/launcher/launcher -k 15 + exit +fi +echo ERROR: $lines reports out of $total_nodes and prods = $prodsfound +programs/launcher/launcher -k 15 +echo ================================================================= +echo Contents of tn_data_00/config.ini: +cat tn_data_00/config.ini +echo ================================================================= +echo Contents of tn_data_00/stderr.txt: +cat tn_data_00/stderr.txt +exit 1