avito-tech / bioyino

High performance and high-precision multithreaded StatsD server
The Unlicense
228 stars 22 forks source link

Cluster settings when instance in docker #73

Closed syatihoko closed 2 months ago

syatihoko commented 1 year ago

Hello. I receive error:

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'bioyino_raft' panicked at 'no entry found for key', /usr/local/cargo/git/checkouts/raft-tokio-77bb75eade836e87/212ec9b/src/tcp.rs:177:37

When I have the following settings:

[raft]
this-node="%real_server_ip%:8138"
nodes = {"%node_ip1%:8138" = 1,"%node_ip2%:8138" = 2,"%node_ip3%:8138" = 3}
# client-bind = "127.0.0.0:8138"

or

[raft]
this-node="%real_server_ip%:8138"
nodes = {"%node_ip1%:8138" = 1,"%node_ip2%:8138" = 2,"%node_ip3%:8138" = 3}
client-bind = "0.0.0.0:8138"

or

[raft]
this-node= "0.0.0.0:8138"
nodes = {"%node_ip1%:8138" = 1,"%node_ip2%:8138" = 2,"%node_ip3%:8138" = 3}
# client-bind = "127.0.0.0:8138"

Error:

thread 'bioyino_raft' panicked at 'no entry found for key', /usr/local/cargo/git/checkouts/raft-tokio-77bb75eade836e87/212ec9b/src/tcp.rs:177:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'bioyino_raft' panicked at 'tcp listener couldn't start: Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" }', /usr/local/cargo/git/checkouts/raft-tokio-77bb75eade836e87/212ec9b/src/lib.rs:237:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Works without error with the following settings, but I'm not sure if they are correct. Help me, tell me how to do it right:

[raft]
this-node= "0.0.0.0:8138"
nodes = {"%node_ip1%:8138" = 1,"%node_ip2%:8138" = 2,"%node_ip3%:8138" = 3}
client-bind = "0.0.0.0:8138"
syatihoko commented 1 year ago

But with such settings, metrics are not sent testing - echo 'tmp.prefix.kaa:11|g' | nc -4u -w0 10.10.10.10 8126

Jan 19 16:35:19.743 INFO skipped send to non-connected peer, remote: 1, thread: compat, program: bioyino
Jan 19 16:35:19.879 INFO stats, qu-len:  0, qu-err:  0, pe-err:  0, p-err:  0, a-err:  0, drops:  0, ingress-m-p:  0, ingress-m: 0.2, ingress:  4, egress-p:  0, egress-c:  0, source: stats, thread: main, program: bioyino
Jan 19 16:35:20.369 INFO skipped send to non-connected peer, remote: 3, thread: compat, program: bioyino
Jan 19 16:35:20.369 INFO skipped send to non-connected peer, remote: 2, thread: compat, program: bioyino
Jan 19 16:35:20.369 INFO skipped send to non-connected peer, remote: 1, thread: compat, program: bioyino
Jan 19 16:35:21.020 INFO skipped send to non-connected peer, remote: 3, thread: compat, program: bioyino
Albibek commented 1 year ago

Hi.

Current implementation of Raft expects to know what IP address it is running on. So, make sure you have IP address in this-node set up for the address from nodes list and match current node's IP address. E.g. for the instance of bioyino running on node1 this-node should be set to '%node_ip1%:8138'.

For client-bind you actually don't need to specify it unless you have some specific cases, like multiple IP addresses on the same node, but it should not break anything in your example.

syatihoko commented 1 year ago

Hello. Albibek, Thanks for such a prompt response! It looks like the "this-node" parameter is used for more than just finding a cluster member. The "this-node" parameter is also used to specify on which ip address and port to host the Raft service. In an implementation without a docker, this will work, but inside the docker you can’t raise a service on the host’s IP address (here it was necessary to use 0.0.0.0:8138). These are my assumptions.

Error:

thread 'bioyino_raft' panicked at 'tcp listener couldn't start: Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" }', /usr/local/cargo/git/checkouts/raft-tokio-77bb75eade836e87/212ec9b/src/lib.rs:237:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
syatihoko commented 1 year ago

About cluster from docker. Most likely it will help if the docker network is switched from bridge to host. I'll check and write back.

Albibek commented 1 year ago

Let me clarify this. The parameters you set in the nodes are the "advertised ones", i.e. the IPs that other nodes use to connect to each other. When you run bioyino in docker, you can either set client-bind to the IP that is provided inside the container or nto set it at all.

So your working configuration is correct, but you may try skipping client-bind at all if you want.