Browse Source

Merge pull request #422 from tendermint/fix-race

Fix race
pull/424/head
Ethan Buchman 8 years ago
committed by GitHub
parent
commit
a200505ae5
6 changed files with 23 additions and 19 deletions
  1. +2
    -0
      consensus/state.go
  2. +4
    -4
      proxy/multi_app_conn.go
  3. +11
    -11
      rpc/client/rpc_test.go
  4. +1
    -0
      rpc/core/abci.go
  5. +3
    -4
      test/persist/test_failure_indices.sh
  6. +2
    -0
      types/part_set.go

+ 2
- 0
consensus/state.go View File

@ -122,6 +122,8 @@ func (rs RoundStepType) String() string {
//-----------------------------------------------------------------------------
// Immutable when returned from ConsensusState.GetRoundState()
// TODO: Actually, only the top pointer is copied,
// so access to field pointers is still racey
type RoundState struct {
Height int // Height we are working on
Round int


+ 4
- 4
proxy/multi_app_conn.go View File

@ -1,7 +1,7 @@
package proxy
import (
. "github.com/tendermint/go-common"
cmn "github.com/tendermint/go-common"
cfg "github.com/tendermint/go-config"
)
@ -9,7 +9,7 @@ import (
// Tendermint's interface to the application consists of multiple connections
type AppConns interface {
Service
cmn.Service
Mempool() AppConnMempool
Consensus() AppConnConsensus
@ -32,7 +32,7 @@ type Handshaker interface {
// which ensures the app and tendermint are synced.
// TODO: on app restart, clients must reboot together
type multiAppConn struct {
BaseService
cmn.BaseService
config cfg.Config
@ -52,7 +52,7 @@ func NewMultiAppConn(config cfg.Config, clientCreator ClientCreator, handshaker
handshaker: handshaker,
clientCreator: clientCreator,
}
multiAppConn.BaseService = *NewBaseService(log, "multiAppConn", multiAppConn)
multiAppConn.BaseService = *cmn.NewBaseService(log, "multiAppConn", multiAppConn)
return multiAppConn
}


+ 11
- 11
rpc/client/rpc_test.go View File

@ -66,17 +66,17 @@ func TestNetInfo(t *testing.T) {
// FIXME: This seems to trigger a race condition with client.Local
// go test -v -race . -run=DumpCons
// func TestDumpConsensusState(t *testing.T) {
// for i, c := range GetClients() {
// // FIXME: fix server so it doesn't panic on invalid input
// nc, ok := c.(client.NetworkClient)
// require.True(t, ok, "%d", i)
// cons, err := nc.DumpConsensusState()
// require.Nil(t, err, "%d: %+v", i, err)
// assert.NotEmpty(t, cons.RoundState)
// assert.Empty(t, cons.PeerRoundStates)
// }
// }
func TestDumpConsensusState(t *testing.T) {
for i, c := range GetClients() {
// FIXME: fix server so it doesn't panic on invalid input
nc, ok := c.(client.NetworkClient)
require.True(t, ok, "%d", i)
cons, err := nc.DumpConsensusState()
require.Nil(t, err, "%d: %+v", i, err)
assert.NotEmpty(t, cons.RoundState)
assert.Empty(t, cons.PeerRoundStates)
}
}
func TestGenesisAndValidators(t *testing.T) {
for i, c := range GetClients() {


+ 1
- 0
rpc/core/abci.go View File

@ -16,6 +16,7 @@ func ABCIQuery(path string, data []byte, prove bool) (*ctypes.ResultABCIQuery, e
if err != nil {
return nil, err
}
log.Info("ABCIQuery", "path", path, "data", data, "result", resQuery)
return &ctypes.ResultABCIQuery{resQuery}, nil
}


+ 3
- 4
test/persist/test_failure_indices.sh View File

@ -58,10 +58,9 @@ for failIndex in $(seq $failsStart $failsEnd); do
bash ./test/utils/txs.sh "localhost:46657" &
start_procs 1 "$failIndex"
# tendermint should fail when it hits the fail index
kill -9 "$PID_DUMMY"
wait "$PID_DUMMY"
wait "$PID_TENDERMINT"
# tendermint should already have paniced when it hits the fail index
# but kill -9 for OS cleanup
kill_procs
start_procs 2


+ 2
- 0
types/part_set.go View File

@ -268,6 +268,8 @@ func (ps *PartSet) StringShort() string {
if ps == nil {
return "nil-PartSet"
} else {
ps.mtx.Lock()
defer ps.mtx.Unlock()
return fmt.Sprintf("(%v of %v)", ps.Count(), ps.Total())
}
}

Loading…
Cancel
Save