codecrafters-io / build-your-own-redis

Definition for the redis challenge.
https://app.codecrafters.io/courses/redis/overview
MIT License
108 stars 30 forks source link

CC-1030: Replace usage of SO_REUSEPORT with SO_REUSEADDR. #139

Closed ryan-gang closed 4 months ago

ryan-gang commented 4 months ago

In our Redis Replication extension, during stage N, the user's code initiates a TCPListener that binds to a specific HOST:PORT. Shortly after, within a few seconds upon progressing to stage N+1, our system attempts to start another TCPListener bound to the identical HOST:PORT. To ensure seamless operation and prevent test failures in this scenario, it's essential to enable the SO_REUSEADDR option on both Listeners. Without activating SO_REUSEADDR, the system will block any attempts to bind a new socket to the same HOST:PORT for a duration of 30 seconds, when it is in TIME_WAIT stage.

Fixes : https://github.com/codecrafters-io/build-your-own-redis/issues/125

linear[bot] commented 4 months ago

CC-1030 Replication stage 3 - listen tcp :6379: bind: address already in use