Hoverbear / old-raft-rs

[Incomplete] A Raft implementation in Rust
https://hoverbear.github.io/raft-rs/raft/
MIT License
266 stars 41 forks source link

test_invalid_peer_message issues. #40

Closed Hoverbear closed 9 years ago

Hoverbear commented 9 years ago

I've been working on getting more tests passing and had a bit of confusion when I worked on this one.

Particularly, between these lines:

        // Check that the server resets the connection.
        assert!(!peer_connected(&server, peer_id));

        // Check that the server reconnects after a timeout.
        event_loop.run_once(&mut server).unwrap();
        assert!(peer_connected(&server, peer_id));

There is the output:

WARN:raft::server: Server(0): unable to reconnect connection PeerConnection(1): No such file or directory (os error 2)

So I dug into this a bit more and it looks like the addresses are still correct:

INFO:raft::connection: PeerConnection(1): PeerConnection(1) reset, will attempt to reconnect in 1ms
SERVER peer_listener.local_addr Ok(V4(127.0.0.1:52996))
CONENCTION &self.addr V4(127.0.0.1:52996)
WARN:raft::server: Server(0): unable to reconnect connection PeerConnection(1): No such file or directory (os error 2)
INFO:raft::connection: PeerConnection(1): PeerConnection(1) reset, will attempt to reconnect in 2ms

It appears that, since .accept() blocks and .run_once() will timeout and attempt any reconnections later, that we need to use threads for this.

Steps to Reproduce

Running:

RUST_BACKTRACE=1 RUST_LOG=raft=debug cargo test server::test::test_invalid_peer_message -- --nocapture

Results in:

   Compiling raft v0.0.1 (file:///home/hoverbear/git/raft)
     Running target/debug/raft-2564fa585e85f017

running 1 test
WARN:raft::server: Server(0): unable to read message from connection PeerConnection(1): Too many segments. 544173927
INFO:raft::connection: PeerConnection(1): PeerConnection(1) reset, will attempt to reconnect in 1ms
WARN:raft::server: Server(0): unable to reconnect connection PeerConnection(1): No such file or directory (os error 2)
INFO:raft::connection: PeerConnection(1): PeerConnection(1) reset, will attempt to reconnect in 3ms
thread 'server::test::test_invalid_peer_message' panicked at 'assertion failed: peer_connected(&server, peer_id)', src/server.rs:647
stack backtrace:
   1:     0x7fa33415dd6e - sys::backtrace::write::h15a4b63788f03a48Lqs
   2:     0x7fa3341615a5 - panicking::on_panic::hb2be65ef48ba45c7x8w
   3:     0x7fa3341502de - rt::unwind::begin_unwind_inner::h7715c8393aa9ab22bOw
   4:     0x7fa333f86f5c - rt::unwind::begin_unwind::h7486876601310146003
                        at ../src/libstd/rt/unwind/mod.rs:226
   5:     0x7fa33402d3dc - server::test::test_invalid_peer_message::h35a7d4744496fb46Rte
                        at /home/hoverbear/git/raft/<std macros>:3
   6:     0x7fa3341169bb - boxed::F.FnBox<A>::call_box::h13048783864144726396
   7:     0x7fa334119602 - boxed::F.FnBox<A>::call_box::h18335448938110916136
   8:     0x7fa334117189 - rt::unwind::try::try_fn::h14476505343823023914
   9:     0x7fa334166558 - rust_try_inner
  10:     0x7fa334166545 - rust_try
  11:     0x7fa33415ba77 - rt::unwind::try::inner_try::h4aec366d17d47bf74Jw
  12:     0x7fa33411739b - boxed::F.FnBox<A>::call_box::h17184265902114669240
  13:     0x7fa3341600d1 - sys::thread::Thread::new::thread_start::hf963e12f2a91a5c1RTv
  14:     0x7fa33307d353 - start_thread
  15:     0x7fa333882bfc - __clone
  16:                0x0 - <unknown>
test server::test::test_invalid_peer_message ... FAILED

failures:

failures:
    server::test::test_invalid_peer_message

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

thread '<main>' panicked at 'Some tests failed', ../src/libtest/lib.rs:255
stack backtrace:
   1:     0x7fa33415dd6e - sys::backtrace::write::h15a4b63788f03a48Lqs
   2:     0x7fa3341615a5 - panicking::on_panic::hb2be65ef48ba45c7x8w
   3:     0x7fa3341502de - rt::unwind::begin_unwind_inner::h7715c8393aa9ab22bOw
   4:     0x7fa3340f5f51 - rt::unwind::begin_unwind::h12493904594067527910
   5:     0x7fa3340f7a1c - test_main::hb10c8419fae025ddI1a
   6:     0x7fa3340fe212 - test_main_static::h2b25e06dfb75b8e4d4a
   7:     0x7fa334037bcc - __test::main::h60e40451e081d021OBh
   8:     0x7fa334166558 - rust_try_inner
   9:     0x7fa334166545 - rust_try
  10:     0x7fa3341630d8 - rt::lang_start::hc2bc8270d37f18e3u3w
  11:     0x7fa334037d4b - main
  12:     0x7fa3337bb78f - __libc_start_main
  13:     0x7fa333f85dd8 - _start
  14:                0x0 - <unknown>
tbg commented 8 years ago

whatever happened to this? We've got #61, but wonder why this got closed.

Hoverbear commented 8 years ago

I think I managed to track down this particular error, sadly I didn't attach a ref to the commit.