[ 
https://issues.apache.org/jira/browse/PHOENIX-5812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17074012#comment-17074012
 ] 

Mingliang Liu commented on PHOENIX-5812:
----------------------------------------

Thanks [~dbwong] and [~ckulkarni] The connection lifetime open/close logic is 
all in client side, so per-connection level property makes more sense. Ideally, 
we can also support user/thread level settings: so for all her connections in 
current JVM, a user's threshold can be set only once. Fo course, a connection's 
property if defined will override that. But this is not required.

I think if I take (some of) this work up, we can make this an umbrella JIRA. 
And sub-task JIRAs can be:
# In CQS interface, support {{closeConnectionIf(Predicate<PhoenixConnection>)}} 
API, which will close all connections with given predicate. This API can be 
used by other use cases where connections maybe closed off-band (not by client 
per se). I have an idea of closing connection for two cluster failover use 
case, and I think this exposed API can be also used there. Potentially there 
may be other use cases in future. The idea is simple: since off-band connection 
close is supported, we can make it a little bit generic.
# Add {{ScheduledExecutorService}} or alike daemon thread per CQS level, which 
will add fixed scheduled task to reap those idle connections. The task is 
simply calling {{closeConnectionIf(PhoenixConnection::isIdle)}}
# Define {{phoenix.connection.lifetime}} property/field for connection and 
implement {{PhoenixConnection::isIdle}} API by tracking the last interacted 
time.
# Metrics, config, doc and integration tests etc

Does that make sense? Breaking this work item down will make it easy to 
collaborate and test. I know [~pawan.prakash] also would like to contribute to 
this if possible. If you already have a plan, we can review and discuss here, 
and see how we can collaborate.

> Automatically Close "Idle" Long Open Connections
> ------------------------------------------------
>
>                 Key: PHOENIX-5812
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5812
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Daniel Wong
>            Priority: Major
>
> As Phoenix may keep a maximum default number of connections.  Badly 
> performing client calls or internal errors (See PHOENIX-5802).  Can cause 
> total available connections to go to 0.  Proposing a client connection 
> monitor with a connection reaper like task to reap idle connections.
> Definition of "Idle"
> Simple may be simple time based say if a connection has been open for 
> configurable amount of minutes simply close.
> More complicated solution may be keeping track of last interaction time.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to