# Stuck at redis #NA2

**URL:** <https://forum.codecrafters.io/t/stuck-at-redis-na2/1047>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [July 15, 2024, 10:48am UTC](https://forum.codecrafters.io/t/stuck-at-redis-na2/1047 "2024-07-15T10:48:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgtuk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/pgtuk/32/925_2.png) [@pgtuk](https://forum.codecrafters.io/u/pgtuk)\
**Post date:** [July 15, 2024, 10:48am UTC](https://forum.codecrafters.io/t/stuck-at-redis-na2/1047/1 "2024-07-15T10:48:15Z")

</div>

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:

 ![Screenshot 2024-07-15 134422](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/9de4993c6d0e008d23c8367927972f5f9d31f7ba.png)

```auto
#[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());
                }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [July 15, 2024, 5:25pm UTC](https://forum.codecrafters.io/t/stuck-at-redis-na2/1047/2 "2024-07-15T17:25:55Z")

</div>

@pgtuk the connection reset seems to happen after the test fails and everything is being closed down (note the “Terminating program” log).

The tester doesn’t make spawn replicas with broken connections - some of them might not reply to ACKs but their connections _should_ stay alive.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [July 20, 2024, 5:25pm UTC](https://forum.codecrafters.io/t/stuck-at-redis-na2/1047/3 "2024-07-20T17:25:56Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
