Skip to content

fix a STOPPED to ACTIVE issue by start method#7

Closed
383124397 wants to merge 1 commit intoapache:4.1.xfrom
383124397:4.1.x
Closed

fix a STOPPED to ACTIVE issue by start method#7
383124397 wants to merge 1 commit intoapache:4.1.xfrom
383124397:4.1.x

Conversation

@383124397
Copy link

@383124397 383124397 commented Mar 19, 2018

We use httpasyncclient as our core async RPC component, but we found a recovering issue a couple days ago.
it is the async client will be stoped because of I/O reactor shutdown when a service encounter a OOM problem, a few seconds later and after a FGC process, the service has been recovered, but the async client cannot be recovered. so the client cannot accept the request unless the service need to reboot.

the code is:

@Override 
public void run() { 
    try { 
        final IOEventDispatch ioEventDispatch = new InternalIODispatch(handler); 
        connmgr.execute(ioEventDispatch);
     } catch (final Exception ex) { 
        log.error("I/O reactor terminated abnormally", ex);
     } finally {
        status.set(Status.STOPPED);
     }
 }

or by close() method.
so there is no way to set status from STOPPED to ACTIVE even by start().

@ok2c
Copy link
Member

ok2c commented Mar 19, 2018

@383124397 Why do you want to restart a shut down HttpAsyncClient instance instead of creating a new one?

@383124397
Copy link
Author

@ok2c I mean there is no way to recover a stopped client if it was shut by a accident exception like seconds
OOM unless the user renew one. but as a user I don't wanna renew an already exists, so I need to add this logic for start method : )

@ok2c
Copy link
Member

ok2c commented Mar 19, 2018

@383124397 I have never ever seen a complex system capable of recovering from OOM condition and I have seen a few. I personally would not attempt to recover a shut down client and would simply create a new one.

@383124397
Copy link
Author

@ok2c so the asynchttpclient is a one-off component for users, I hope it could be resiliently, high availability... and you know it could be caused memory leak if we create new client outside frequently.

@ok2c
Copy link
Member

ok2c commented Mar 20, 2018

@383124397 Your own application causes OOM condition and you are worrying about resiliently and high availability of HttpAsyncClient?

@383124397
Copy link
Author

@ok2c I mean it's is good enough if the HttpAsyncClient can support be recovered from an exception scenario by invoke start method.

@ok2c
Copy link
Member

ok2c commented Mar 22, 2018

@383124397 OOM in Java is considered a fatal error. If HttpAsycClient was unable to allocate some of its internal structures it may no longer be in a consistent state. This is the reason why it shuts down upon encountering OOM in the first place. It makes no sense to restart a shut down instance. It is much safer to create a new one.

@ok2c
Copy link
Member

ok2c commented Mar 27, 2018

@383124397 Would you mind closing this PR?

@383124397
Copy link
Author

@ok2c OK

@383124397 383124397 closed this Mar 28, 2018
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

Successfully merging this pull request may close these issues.

2 participants