Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Losing logs #596

Open
maxgttph opened this issue Jan 13, 2025 · 2 comments
Open

Losing logs #596

maxgttph opened this issue Jan 13, 2025 · 2 comments

Comments

@maxgttph
Copy link
Contributor

maxgttph commented Jan 13, 2025

Some logs got lost.
How to reproduce:
-> Change tcp_server.rs handle_message to add some logs:

        module_handle_messages! {
            on_bus self.bus,

            Ok((tcp_stream, addr)) = tcp_listener.accept() => {
                tracing::error!("New connection from: {:?}", addr);
                println!("New connection from: {:?}", addr);
                let r = rand::random::<u64>();
                let sender: &tokio::sync::broadcast::Sender<TcpServerMessage> = self.bus.get();
                let sender = sender.clone();
                readers.spawn(async move {
                    let mut framed = Framed::new(tcp_stream, LengthDelimitedCodec::new());
                    loop {
                        match read_stream(&mut framed).await {
                            Ok(TcpServerNetMessage::NewTx(tx)) => {
                                tracing::error!("Received new transaction from: {:?}, r = {}", addr, r);
                                let tx_hash = tx.hash();
                                sender.send(TcpServerMessage::NewTx(tx))?;
                                // TODO: Wrap resp in a TcpServerMessageResponse enum ?
                                framed.get_mut().write_all(tx_hash.0.as_bytes()).await?;
                            },
                            Ok(TcpServerNetMessage::Ping) => {
                                framed.get_mut().write_all(b"Pong").await?;
                            },
                            Err(e) => { bail!("Error reading stream: {}", e); }
                        };
                    }
                });
            }
        }

-> Comment the tokio::time::sleep in loadtest lib file
-> In loadtest, change number_of_task to only keep 2 (for readability)
-> Run load test. You should now be able to see that multiple transactions have been received, while there is only one log of new connection. You should also see the println of the connection without its associated log

@Supa-mega
Copy link

Mind if I try this one?

@hhalex
Copy link
Contributor

hhalex commented Feb 21, 2025

For information, most of this code has been extracted in a connection pool implementation, but may be the log problem is still there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants