koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

Crash when AMQP is not connected #43

Closed theoreticalbts closed 3 years ago

theoreticalbts commented 3 years ago

I inadvertently misconfigured AMQP to dial the wrong port, I got this in the logs when a peer tried to connect to me:

2021/02/17 16:46:26 Connecting to AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:26 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:26 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:46:26 Starting node at address: /ip4/10.89.0.35/tcp/8889/p2p/QmSNE2wo3hH8Yfnwn9GERrD6ziyLRZkYPK8FsZHthMjZMM
2021/02/17 16:46:27 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:27 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:46:30 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:30 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:46:35 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:35 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:46:42 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:42 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:46:51 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:46:51 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:47:02 Dialing AMQP server amqp://guest:guest@localhost:5673/
2021/02/17 16:47:02 AMQP error dialing server: dial tcp 127.0.0.1:5673: connect: connection refused
2021/02/17 16:47:14 Peer connected to us to sync: QmfVKgvmDy-1-3
2021/02/17 16:47:14 QmfVKgvmDy-1-3: checking peer's chain id
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc pc=0x6608d5]

goroutine 16 [running]:
github.com/streadway/amqp.(*Channel).Publish(0x0, 0xb143a9, 0xa, 0xc000026690, 0x10, 0xc000020000, 0x0, 0xb17ecd, 0x10, 0x0, ...)
        /root/go/pkg/mod/github.com/streadway/amqp@v1.0.0/channel.go:1331 +0x75
github.com/koinos/koinos-mq-golang.(*KoinosMQ).SendRPC(0xc00024a280, 0xb17ecd, 0x10, 0xb0f536, 0x5, 0xc0005b4440, 0x3d, 0x40, 0x3c, 0x8, ...)
        /opt/koinos-src/koinos-mq-golang/koinosmq.go:254 +0x245
github.com/koinos/koinos-p2p/internal/rpc.KoinosRPC.GetChainID(0xc00024a280, 0xa2c8c0, 0x1, 0x114b630)
        /opt/koinos-src/koinos-p2p/internal/rpc/koinos_rpc.go:173 +0xf3
github.com/koinos/koinos-p2p/internal/protocol.SyncProtocol.handleStream(0xcf7860, 0xc0000ac178, 0xcfc240, 0xc000100000, 0xc0001e6010, 0xcfc920, 0xc00000ed60)
        /opt/koinos-src/koinos-p2p/internal/protocol/sync_protocol.go:78 +0x313
github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).SetStreamHandler.func1(0xc0001941a0, 0x12, 0x7f9a6410b1c8, 0xc00000ed60, 0x1, 0x0)
        /root/go/pkg/mod/github.com/libp2p/go-libp2p@v0.13.0/p2p/host/basic/basic_host.go:566 +0x9f
created by github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).newStreamHandler
        /root/go/pkg/mod/github.com/libp2p/go-libp2p@v0.13.0/p2p/host/basic/basic_host.go:416 +0x613

Running integration-clean branch (commit 095d36b14610e56334756e5256c6de2c2bf822ee)

mvandeberg commented 3 years ago

I was able to shutdown and restart amqp with an entire koinos node running and everything was able to reconnect and resume normal operation.