dice icon indicating copy to clipboard operation
dice copied to clipboard

Add explicit handling for max clients connected to the server

Open JyotinderSingh opened this issue 1 year ago • 13 comments

The below code snippet is used inside async_tcp.go, however, it cannot effectively limit the maximum number of clients connected to the server. We need to add an explicit check for the same.

if err := syscall.Listen(s.serverFD, s.maxClients); err != nil {
		return err
	}

Context: https://github.com/DiceDB/dice/pull/410#discussion_r1731693923

JyotinderSingh avatar Aug 27 '24 12:08 JyotinderSingh

Can I pick this up?

cskarthik7 avatar Aug 27 '24 13:08 cskarthik7

I would like to work on this one

TheRanomial avatar Aug 29 '24 06:08 TheRanomial

https://github.com/DiceDB/dice/pull/426/files @JyotinderSingh Can you have a look ?

ayush571995 avatar Aug 29 '24 17:08 ayush571995

@ ayush571995 I also have the same code as you, but how did you test it?

evoxtorm avatar Aug 30 '24 14:08 evoxtorm

@ ayush571995 I also have the same code as you, but how did you test it?

In local for testing i changed the max connection limit to 1 Umm using dice cli from terminal I created multiple connections and got the failure when exceeded limit

ayush571995 avatar Aug 30 '24 14:08 ayush571995

@ayush571995 Thanks, I was writing a test case, I tried something like this, and I don't know why it failed for me. Am I missing something here?

connections := make([]net.Conn, 0, config.ServerMaxClients+1)

	for i := 0; i < config.ServerMaxClients+1; i++ {
		conn := getLocalConnection()
		if conn != nil {
			connections = append(connections, conn)
		}
		time.Sleep(100 * time.Millisecond) 
	}

	// t.Log(len(connections), " This is log", config.ServerMaxClients)
	assert.Equal(t, config.ServerMaxClients, len(connections), "Should only be able to open maxClients connections")

evoxtorm avatar Aug 30 '24 15:08 evoxtorm

Since @ayush571995 already created a draft PR for this, assigning this to him.

JyotinderSingh avatar Sep 01 '24 16:09 JyotinderSingh

Hello @ayush571995,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

arpitbbhayani avatar Sep 09 '24 09:09 arpitbbhayani

Hey @arpitbbhayani @JyotinderSingh Sorry I missed this . Will push the changes today

ayush571995 avatar Sep 09 '24 09:09 ayush571995

@arpitbbhayani @JyotinderSingh I was writing a test case for this integration probably but need to discuss one thing about the changes I would like to have a small discussion if possible ?

Question: This test needs to run in isolation and we don't have that setup infra as of now context: I have the changes ready but when i execute the test as part of the test suite it's not able to accquire max connections as some tests have them and it fails

ayush571995 avatar Sep 09 '24 18:09 ayush571995

@arpitbbhayani @JyotinderSingh

I was writing a test case for this integration probably but need to discuss one thing about the changes

I would like to have a small discussion if possible ?

Question:

This test needs to run in isolation and we don't have that setup infra as of now

context:

I have the changes ready but when i execute the test as part of the test suite it's not able to accquire max connections as some tests have them and it fails

Apologies for the late reply, missed this comment. We now have a server directory under integration_tests/. You can add a test there, the tests in this directory do not launch a default server instance. You have more control over the server configuration and testing there. Please take a look if you can make it work there.

JyotinderSingh avatar Sep 14 '24 19:09 JyotinderSingh

Folks, Just a nudge here as well. The pr is ready since 15th Sept for review

ayush571995 avatar Sep 17 '24 16:09 ayush571995

@ayush571995 can you please resolve conflicts and review comments on PR

lucifercr07 avatar Sep 25 '24 16:09 lucifercr07

Closing, merged as part of https://github.com/DiceDB/dice/pull/426

lucifercr07 avatar Sep 29 '24 18:09 lucifercr07