dice icon indicating copy to clipboard operation
dice copied to clipboard

Unhandled "Port Address already in use"

Open pranjal-verma opened this issue 3 years ago • 12 comments

Describe the bug When running dice on a port that is already occupied by another process, dice simply exits without any error message or exit status.

To Reproduce Steps to reproduce the behavior:

  1. Run dice on a port that is already in use. Screenshot from 2022-11-11 00-40-23(1)

Expected behavior Dice exits with exit status 1 and an error message like "bind: Address already in use"

pranjal-verma avatar Nov 10 '22 19:11 pranjal-verma

@arpitbbhayani can I try this one to start with. looks like a simple log change.

ameyajoshi35 avatar Nov 10 '22 20:11 ameyajoshi35

Go for it @ameyajoshi35

arpitbbhayani avatar Nov 11 '22 02:11 arpitbbhayani

@arpitbbhayani @ameyajoshi35 it would be good if there would be a free port finder module which can be developed as a pluggable solution.

For instance, in development mode we can enable this module as there would be many instances where we would stop and restart the DB and but in production mode we can disable it.

rohanverma94 avatar Nov 11 '22 05:11 rohanverma94

@rohanverma94 let's have a set of ports that we check if none of them are free we panic. Otherwise that port is assigned. Whatvsay?

arpitbbhayani avatar Nov 11 '22 05:11 arpitbbhayani

@arpitbbhayani yes this works, a must read regarding the problem - https://onlinehelp.opswat.com/centralmgmt/What_you_need_to_do_if_you_see_too_many_TIME_WAIT_sockets.html

rohanverma94 avatar Nov 11 '22 05:11 rohanverma94

@arpitbbhayani @rohanverma94 can you take a look at https://github.com/DiceDB/dice/pull/98 I was looking for a free port finder, we can add that as well but it picks up a random port. may be we can filter that as well. But as arpit suggested to keep it simple, I have added just a couple of ports and if in case unavailable in debug mode, code will try to start up on set of ports.

ameyajoshi35 avatar Nov 11 '22 16:11 ameyajoshi35

@ameyajoshi35 Well as @arpitbbhayani suggested you can further narrow down the search for free ports, you don't have to search on an infinite range. It would be more like doing a sequential port scan on a fixed range. The thing is even if some port is under "TIME_WAIT" then I can just try the next port. The extended problem of "TIME_WAIT" is based on TCP and something we can't get away from, we must have to wait till it is released by OS.

I manually mitigate the "address in use" problem (in case of wrong logic in process) - I just kill via kill -9 <pid-of-7379>

However, it is tedious for development and hence I should be able to start the DB over a port range.

rohanverma94 avatar Nov 11 '22 16:11 rohanverma94

I realise that this thread has been idle for a while and this looks like a good first issue. Can I pick this up @arpitbbhayani ?

sriramr98 avatar May 06 '23 18:05 sriramr98

Hi, @arpitbbhayani @rohanverma94 shall I pick this up if it's still available ? 🚀

reapedjuggler avatar Jun 11 '23 13:06 reapedjuggler

feel free to pick this up as my PR is not ready yet.

On Sun, Jun 11, 2023 at 7:20 PM Vibhav Tomar @.***> wrote:

Hi, @arpitbbhayani https://github.com/arpitbbhayani @rohanverma94 https://github.com/rohanverma94 shall I pick this up if it's still available ? 🚀

— Reply to this email directly, view it on GitHub https://github.com/DiceDB/dice/issues/95#issuecomment-1586174423, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICFWHZKUDCOLCBQHIIUI4DXKXEKNANCNFSM6AAAAAAR44S4YI . You are receiving this because you were mentioned.Message ID: @.***>

ameyajoshi35 avatar Jun 11 '23 17:06 ameyajoshi35

Thank you for the heads up @ameyajoshi35

reapedjuggler avatar Jun 12 '23 17:06 reapedjuggler

Hi, @arpitbbhayani @pranjal-verma @rohanverma94 Can you please check my PR and please review it once? #107

reapedjuggler avatar Jun 12 '23 18:06 reapedjuggler