I’m stuck on Stage #NA2.
I get it that we don’t receive ACK
from some replicas. If replica doesn’t respond to GETACK
i get connection reset by peer
error, which is handled as if connection has been closed. But tests expect command propagation for this kind of replicas, which i don’t understand how is it possible.
I can’t propagate commands via this exact connection, replica should’ve reconnected.
I would appreciate any help, stuck on this one for too long.
Here are my logs:
#[derive(Debug)]
pub struct Connection {
stream: BufWriter<TcpStream>,
buffer: BytesMut,
pub(crate) is_repl_conn: bool,
}
impl Connection {
pub fn new(stream: TcpStream) -> Connection {
// let (reader, writer) = stream.split()
Connection {
stream: BufWriter::new(stream),
buffer: BytesMut::with_capacity(4096),
is_repl_conn: false,
}
}
pub async fn read_frame(&mut self) -> Result<Option<Frame>, FrameError> {
loop {
if let Some(frame) = self.parse_frame()? {
return Ok(Some(frame));
};
if 0 == self.stream.read_buf(&mut self.buffer).await? {
if self.buffer.is_empty() {
return Ok(None);
} else {
return Err("connection reset by peer".into());
}
}
}
}
}