You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Victor <dr...@mail333.com> on 2009/04/24 15:47:18 UTC

IoSession in PREPARING state is not removed from queue

Hello mina developers!

Seems I have found a bug with IoSession (or I am doing something wrong 
:) ) - I can see that a "PREPARING" session is not removed correctly 
from queue.

When some session is in PREPARING state, it is removed from 
"removingSessions" queue but right after that it is added to this queue 
again! So this session is added to the queue and removed from it until 
forever.
As a result, this give us significant garbage allocation, so CPU spends 
most of time in garbage collector (I can see this is JConsole).

I see comments there in AbstractPollingIoProcessor class:

private int remove() {
...
	case PREPARING:
                 // Retry later if session is not yet fully initialized.
                 // (In case that Session.close() is called before 	 
addSession() is processed)
                 scheduleRemove(session);
                 return removedSessions;
...
}

I have added logging to this code, and I can see that the SAME session 
is removed and added again and again.

Can somebody explain this logic please? Why don't we remove the PENDING 
  session? Or maybe is there a workaround for this.

Sorry, I can not provide a test for this issue, but it is reproduced 
almost every day at out production servers under some load. Maybe, you 
can reproduce it by adding a delay in addSession() and then closing the 
session during this delay.

Thanks for any ideas and propositions,

Victor

Re: IoSession in PREPARING state is not removed from queue

Posted by Victor <dr...@mail333.com>.
Thanks Emmanuel!

I have added it to JIRA:
https://issues.apache.org/jira/browse/DIRMINA-709

Victor

Emmanuel Lecharny wrote:
> Hi Victor,
> 
> first, thanks for your investigation and the proposed solution.
> 
> Could you create a JIRA with all the elements you provided, so that it
> don't get lost forever in the mailing list ? We probably will be able
> to process this later (all of us are quite busy those days), but if
> it's a JIRA, it won't get forgetten.
> 
> Many thanks !
> 
> 2009/5/4 Victor <dr...@mail333.com>:
>> Seems that my patch is working - I can see that several pending sessions
>> were removed during last 3 days on our servers.
>> I hope that it does not have impact on some other functions of mina :)
>>
>> Anyway, it would be great to see comments from mina creators!
>>
>> Victor
>>
>>
>> Victor wrote:
>>> Sorry, I forgot to say that I use mina 2.0 M4 (unfortunately, our server
>>> does not work with M5 yet - something changed).
>>>
>>> If I do a simple workaround - call removeNow() for such sessions - can
>>> something go wrong this way?
>>>
>>> Thanks
>>>
>>> Victor
>>>
>>> Victor wrote:
>>>> Hello mina developers!
>>>>
>>>> Seems I have found a bug with IoSession (or I am doing something wrong :)
>>>> ) - I can see that a "PREPARING" session is not removed correctly from
>>>> queue.
>>>>
>>>> When some session is in PREPARING state, it is removed from
>>>> "removingSessions" queue but right after that it is added to this queue
>>>> again! So this session is added to the queue and removed from it until
>>>> forever.
>>>> As a result, this give us significant garbage allocation, so CPU spends
>>>> most of time in garbage collector (I can see this is JConsole).
>>>>
>>>> I see comments there in AbstractPollingIoProcessor class:
>>>>
>>>> private int remove() {
>>>> ...
>>>>    case PREPARING:
>>>>                // Retry later if session is not yet fully initialized.
>>>>                // (In case that Session.close() is called before
>>>>  addSession() is processed)
>>>>                scheduleRemove(session);
>>>>                return removedSessions;
>>>> ...
>>>> }
>>>>
>>>> I have added logging to this code, and I can see that the SAME session is
>>>> removed and added again and again.
>>>>
>>>> Can somebody explain this logic please? Why don't we remove the PENDING
>>>>  session? Or maybe is there a workaround for this.
>>>>
>>>> Sorry, I can not provide a test for this issue, but it is reproduced
>>>> almost every day at out production servers under some load. Maybe, you can
>>>> reproduce it by adding a delay in addSession() and then closing the session
>>>> during this delay.
>>>>
>>>> Thanks for any ideas and propositions,
>>>>
>>>> Victor
>>>>
> 
> 
> 

Re: IoSession in PREPARING state is not removed from queue

Posted by Emmanuel Lecharny <el...@apache.org>.
Hi Victor,

first, thanks for your investigation and the proposed solution.

Could you create a JIRA with all the elements you provided, so that it
don't get lost forever in the mailing list ? We probably will be able
to process this later (all of us are quite busy those days), but if
it's a JIRA, it won't get forgetten.

Many thanks !

2009/5/4 Victor <dr...@mail333.com>:
> Seems that my patch is working - I can see that several pending sessions
> were removed during last 3 days on our servers.
> I hope that it does not have impact on some other functions of mina :)
>
> Anyway, it would be great to see comments from mina creators!
>
> Victor
>
>
> Victor wrote:
>>
>> Sorry, I forgot to say that I use mina 2.0 M4 (unfortunately, our server
>> does not work with M5 yet - something changed).
>>
>> If I do a simple workaround - call removeNow() for such sessions - can
>> something go wrong this way?
>>
>> Thanks
>>
>> Victor
>>
>> Victor wrote:
>>>
>>> Hello mina developers!
>>>
>>> Seems I have found a bug with IoSession (or I am doing something wrong :)
>>> ) - I can see that a "PREPARING" session is not removed correctly from
>>> queue.
>>>
>>> When some session is in PREPARING state, it is removed from
>>> "removingSessions" queue but right after that it is added to this queue
>>> again! So this session is added to the queue and removed from it until
>>> forever.
>>> As a result, this give us significant garbage allocation, so CPU spends
>>> most of time in garbage collector (I can see this is JConsole).
>>>
>>> I see comments there in AbstractPollingIoProcessor class:
>>>
>>> private int remove() {
>>> ...
>>>    case PREPARING:
>>>                // Retry later if session is not yet fully initialized.
>>>                // (In case that Session.close() is called before
>>>  addSession() is processed)
>>>                scheduleRemove(session);
>>>                return removedSessions;
>>> ...
>>> }
>>>
>>> I have added logging to this code, and I can see that the SAME session is
>>> removed and added again and again.
>>>
>>> Can somebody explain this logic please? Why don't we remove the PENDING
>>>  session? Or maybe is there a workaround for this.
>>>
>>> Sorry, I can not provide a test for this issue, but it is reproduced
>>> almost every day at out production servers under some load. Maybe, you can
>>> reproduce it by adding a delay in addSession() and then closing the session
>>> during this delay.
>>>
>>> Thanks for any ideas and propositions,
>>>
>>> Victor
>>>
>>
>



-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: IoSession in PREPARING state is not removed from queue

Posted by Victor <dr...@mail333.com>.
Seems that my patch is working - I can see that several pending sessions 
were removed during last 3 days on our servers.
I hope that it does not have impact on some other functions of mina :)

Anyway, it would be great to see comments from mina creators!

Victor


Victor wrote:
> Sorry, I forgot to say that I use mina 2.0 M4 (unfortunately, our server 
> does not work with M5 yet - something changed).
> 
> If I do a simple workaround - call removeNow() for such sessions - can 
> something go wrong this way?
> 
> Thanks
> 
> Victor
> 
> Victor wrote:
>> Hello mina developers!
>>
>> Seems I have found a bug with IoSession (or I am doing something wrong 
>> :) ) - I can see that a "PREPARING" session is not removed correctly 
>> from queue.
>>
>> When some session is in PREPARING state, it is removed from 
>> "removingSessions" queue but right after that it is added to this 
>> queue again! So this session is added to the queue and removed from it 
>> until forever.
>> As a result, this give us significant garbage allocation, so CPU 
>> spends most of time in garbage collector (I can see this is JConsole).
>>
>> I see comments there in AbstractPollingIoProcessor class:
>>
>> private int remove() {
>> ...
>>     case PREPARING:
>>                 // Retry later if session is not yet fully initialized.
>>                 // (In case that Session.close() is called before      
>> addSession() is processed)
>>                 scheduleRemove(session);
>>                 return removedSessions;
>> ...
>> }
>>
>> I have added logging to this code, and I can see that the SAME session 
>> is removed and added again and again.
>>
>> Can somebody explain this logic please? Why don't we remove the 
>> PENDING  session? Or maybe is there a workaround for this.
>>
>> Sorry, I can not provide a test for this issue, but it is reproduced 
>> almost every day at out production servers under some load. Maybe, you 
>> can reproduce it by adding a delay in addSession() and then closing 
>> the session during this delay.
>>
>> Thanks for any ideas and propositions,
>>
>> Victor
>>
> 

Re: IoSession in PREPARING state is not removed from queue

Posted by Victor <dr...@mail333.com>.
Sorry, I forgot to say that I use mina 2.0 M4 (unfortunately, our server 
does not work with M5 yet - something changed).

If I do a simple workaround - call removeNow() for such sessions - can 
something go wrong this way?

Thanks

Victor

Victor wrote:
> Hello mina developers!
> 
> Seems I have found a bug with IoSession (or I am doing something wrong 
> :) ) - I can see that a "PREPARING" session is not removed correctly 
> from queue.
> 
> When some session is in PREPARING state, it is removed from 
> "removingSessions" queue but right after that it is added to this queue 
> again! So this session is added to the queue and removed from it until 
> forever.
> As a result, this give us significant garbage allocation, so CPU spends 
> most of time in garbage collector (I can see this is JConsole).
> 
> I see comments there in AbstractPollingIoProcessor class:
> 
> private int remove() {
> ...
>     case PREPARING:
>                 // Retry later if session is not yet fully initialized.
>                 // (In case that Session.close() is called before      
> addSession() is processed)
>                 scheduleRemove(session);
>                 return removedSessions;
> ...
> }
> 
> I have added logging to this code, and I can see that the SAME session 
> is removed and added again and again.
> 
> Can somebody explain this logic please? Why don't we remove the PENDING 
>  session? Or maybe is there a workaround for this.
> 
> Sorry, I can not provide a test for this issue, but it is reproduced 
> almost every day at out production servers under some load. Maybe, you 
> can reproduce it by adding a delay in addSession() and then closing the 
> session during this delay.
> 
> Thanks for any ideas and propositions,
> 
> Victor
>