vesoft-inc / nebula-java

Client API and data importer of Nebula Graph in Java
Apache License 2.0
164 stars 121 forks source link

Idle session clean is inaccurate #536

Closed awang12345 closed 8 months ago

awang12345 commented 10 months ago

nebula-java version: 3.6.0 class : com.vesoft.nebula.client.graph.SessionPool

code:

/**

  • update the session queue according to minSessionSize */ private void updateSessionQueue() { // remove the idle sessions if (idleSessionSize.get() > minSessionSize) { synchronized (this) { for (NebulaSession nebulaSession : sessionList) { if (nebulaSession.isIdle()) { nebulaSession.release(); sessionList.remove(nebulaSession); if (idleSessionSize.decrementAndGet() <= minSessionSize) { break; } } } } } }

desc This code logic simply clears the idle session.However, the idle time is not judged.It may be cleared as soon as it enters idle. Although the scheduled tasks are scheduled according to cleanTime.But it still doesn't match the comments of

'cleanTime' propties.

// The idleTime for clean the idle session // must be less than NebulaGraph's session_idle_timeout_secs, unit: second private int cleanTime = 3600;

Nicole00 commented 10 months ago

Sorry for the misunderstanding caused by the configuration item, the cleanTime means how often the client will clean up the idle session, not to clear the session that has been idle for this time.

awang12345 commented 10 months ago

I know cleanTime is the frequency of cleantime,I know cleanTime is the frequency of cleantime,eg:T1、T2、T3 is the timeline of clientTime task schdule.R is the session return to pool. R just release could be recycled. Timeline:-------------------T1--------------------------------T2-------------------------------T3---------------------- Timeline:----------- --R1---------------------------------R2--------------------------------R3--------------------------

Nicole00 commented 9 months ago

Yeah, R is just released and the clean schedule task is triggered, the session R may be recycled if the idle is larger than minSessionSize and R's location is in the front of SessionPool list. Every Session used to make execution is get from session pool, the recycle will not confluence the execution.

awang12345 commented 8 months ago

thank you for the response