Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller does't close socket #314

Closed
dburnazyan opened this issue May 11, 2016 · 3 comments
Closed

Controller does't close socket #314

dburnazyan opened this issue May 11, 2016 · 3 comments

Comments

@dburnazyan
Copy link

Controller does't close socket in PingDriverRunner (perhaps) class so after while too many CLOSE_WAIT connection appear and controller stop working because it can't open new socket.

root@cosbench:~# status cosbench-controller 
cosbench-controller start/running, process 22856
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT | grep 22856/java | wc -l
28233

PingDriverRunner

...
    private void pingDrivers(DriverInfo[] driverInfos) {
        for (DriverInfo driver : driverInfos) {
            boolean isAlive = false;

            String ipAddress = getIpAddres(driver.getUrl());
            Integer port = getDriverPort(driver.getUrl());
            try {
                if (!ipAddress.isEmpty()) { 
                    try{
                        Socket socket = new Socket();
                        InetSocketAddress reAddress = new InetSocketAddress(ipAddress, port);
                        InetSocketAddress locAddress = new InetSocketAddress("0.0.0.0", 0);
                        socket.bind(locAddress);
                        socket.connect(reAddress,3000);
                        isAlive = true;
                        }catch(Exception e){
                            isAlive = false;
                        }
                }
            }finally{
                driver.setAliveState(isAlive);
            }
        }
    }
...

Do we need socket.close(); after socket.connect() ?

@dburnazyan
Copy link
Author

dburnazyan commented May 11, 2016

after restarting controller connection in CLOSE_WAIT state became growing

root@cosbench:~# restart cosbench-controller 
cosbench-controller start/running, process 26232
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l                                                                                                                                                                                   
0
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
18
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
18
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
21
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
21
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
147

@dburnazyan
Copy link
Author

This commit fix it for me
1f1ca14

@dburnazyan
Copy link
Author

Before:

root@cosbench:~# date
Wed May 11 06:48:31 EDT 2016
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
39
root@cosbench:~# date
Wed May 11 06:50:17 EDT 2016
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
102

After:

root@cosbench:~# date
Wed May 11 06:51:46 EDT 2016
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
0
root@cosbench:~# date
Wed May 11 06:55:01 EDT 2016
root@cosbench:~# netstat -tuapn | grep CLOSE_WAIT  | wc -l
0

@ywang19 ywang19 closed this as completed Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants