Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

venkat_99
Hi,
We are using Jetty 7.5.1. We have JDBCSessionManager configured to serialize the JSESSIONID, we have set MaxInactiveTimeInterval as 120.We have two nodes running on the load balancer, what we have observed is whenever a request from a session which was served by node1 before goes to node2 the expiryTime is getting set to zero.

When we tried to debug jetty-server src the below constructor in the AbstractSession

protected AbstractSession(AbstractSessionManager abstractSessionManager, long created, long accessed, String clusterId)
    {
        _manager = abstractSessionManager;
        _created=created;
        _clusterId=clusterId;
        _nodeId=_manager._sessionIdManager.getNodeId(_clusterId,null);
        _accessed=accessed;
        _lastAccessed=accessed;
        _requests=1;
        __log.debug("new session "+_nodeId+" "+_clusterId);
    }

doesn't seem to serialize or set _maxIdleMs whereas in the other constructor it does.
protected boolean access(long time)
        {
            if (super.access(time))
            {
                _data.setLastAccessed(_data.getAccessed());
                _data.setAccessed(time);

                int maxInterval=getMaxInactiveInterval();
                _data.setExpiryTime(maxInterval <= 0 ? 0 : (time + maxInterval*1000));
                return true;
            }
            return false;
        }
 public int getMaxInactiveInterval()
    {
        checkValid();
        return (int)(_maxIdleMs/1000);
    }
Due to this the access method inside of Session is setting the expiryTime of SessionData based on _maxIdleMs of Session which is zero. This is making expiryTime zero. Is this a bug / are we missing some configration in Jetty?



Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

Jan Bartel-3
The JDBCSessionManager persists and reloads the expiry time of the
session into the SessionData (see loadSession(), storeSession() and
updateSession() methods). The session scavenging expiry code does
database queries to find candidates to expire.

The JDBCSessionManager.Session.access() method will reset the expiry
time, so if the session migrates from node1 to node2, that access
method will be called and use the maxIdleTime of the node2 to
calculate the expiry - are you sure node2 has the correct maxIdleTime
set?

If you've checked your config, and you can establish a scenario where
the expiryTime is not being set correctly, I'll certainly take a look
at it.

regards
Jan

On 28 May 2012 14:13, venkat_99 <[hidden email]> wrote:

> Hi,
> We are using Jetty 7.5.1. We have JDBCSessionManager configured to serialize
> the JSESSIONID, we have set MaxInactiveTimeInterval as 120.We have two nodes
> running on the load balancer, what we have observed is whenever a request
> from a session which was served by node1 before goes to node2 the expiryTime
> is getting set to zero.
>
> When we tried to debug jetty-server src the below constructor in the
> AbstractSession
>
> protected AbstractSession(AbstractSessionManager abstractSessionManager,
> long created, long accessed, String clusterId)
>    {
>        _manager = abstractSessionManager;
>        _created=created;
>        _clusterId=clusterId;
>        _nodeId=_manager._sessionIdManager.getNodeId(_clusterId,null);
>        _accessed=accessed;
>        _lastAccessed=accessed;
>        _requests=1;
>        __log.debug("new session "+_nodeId+" "+_clusterId);
>    }
>
> doesn't seem to serialize or set _maxIdleMs whereas in the other constructor
> it does.
> protected boolean access(long time)
>        {
>            if (super.access(time))
>            {
>                _data.setLastAccessed(_data.getAccessed());
>                _data.setAccessed(time);
>
>                int maxInterval=getMaxInactiveInterval();
>                _data.setExpiryTime(maxInterval <= 0 ? 0 : (time +
> maxInterval*1000));
>                return true;
>            }
>            return false;
>        }
>  public int getMaxInactiveInterval()
>    {
>        checkValid();
>        return (int)(_maxIdleMs/1000);
>    }
> Due to this the access method inside of Session is setting the expiryTime of
> SessionData based on _maxIdleMs of Session which is zero. This is making
> expiryTime zero. Is this a bug / are we missing some configration in Jetty?
>
>
>
>
>
> --
> View this message in context: http://jetty.4.n6.nabble.com/Jetty-clustering-not-working-properly-jettySessions-expiryTime-getting-set-to-0-after-sometime-tp4958537.html
> Sent from the Jetty User mailing list archive at Nabble.com.
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

venkat_99
This post was updated on .
Here is the config of JDBCSessionManager we are using on both the nodes

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Get name="server">
        <Get id="jdbcIdMgr" name="sessionIdManager"/>
    </Get>
    <Set name="sessionHandler">
        <New class="org.eclipse.jetty.server.session.SessionHandler">
            <Arg>
                <New class="org.eclipse.jetty.server.session.JDBCSessionManager">
                    <Set name="idManager">
                        <Ref id="jdbcIdMgr"/>
                    </Set>
                    <Set name="SaveInterval" type="long">-60000</Set>
                    <Set name="MaxInactiveInterval" type="int">120</Set>
                </New>
            </Arg>
        </New>
    </Set>
</Configure>

The JDBCSessionIdManager is defined separately in the config file of jetty-7.xml, in our case both the nodes have the maxIdleTime. When I inspected into the methods of access during session migration whenever a session migration happens from one node to other node the second constructor of AbstractSession is being called. In this constructor there is no set like below(first constructor) on the session, due to which session has maxIdleMs set to zero.
_maxIdleMs=_manager._dftMaxIdleSecs>0?_manager._dftMaxIdleSecs*1000:-1;

Where as the access() method of JDBCSessionManager$Session is setting exprityTime on sessionData based on _maxIdleMs of Session which is zero. I think this is causing the issue.


Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

Jan Bartel-3
Venkat,

Thanks for the clear explanation, I raised this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380866

Will let you know when its fixed.

Jan

On 29 May 2012 07:59, venkat_99 <[hidden email]> wrote:

> Here is the config of JDBCSessionManager we are using on both the nodes
>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>    <Get name="server">
>        <Get id="jdbcIdMgr" name="sessionIdManager"/>
>    </Get>
>    <Set name="sessionHandler">
>        <New class="org.eclipse.jetty.server.session.SessionHandler">
>            <Arg>
>                <New
> class="org.eclipse.jetty.server.session.JDBCSessionManager">
>                    <Set name="idManager">
>                        <Ref id="jdbcIdMgr"/>
>                    </Set>
>                    <Set name="SaveInterval" type="long">-60000</Set>
>                    <Set name="MaxInactiveInterval" type="int">120</Set>
>                </New>
>            </Arg>
>        </New>
>    </Set>
> </Configure>
>
> The JDBCSessionIdManager is defined separately in the config file of
> jetty-7.xml, in our case both the nodes have the maxIdleTime. When I
> inspected into the methods of access during session migration whenever a
> session migration happens from one node to other nodes the second
> constructor of AbstractSession is being called. In this constructor there is
> no set like below  on the session, due to which session has maxIdleMs.
> _maxIdleMs=_manager._dftMaxIdleSecs>0?_manager._dftMaxIdleSecs*1000:-1;
>
> Where as the access method of JDBCSessionManager$Session is setting
> exprityTime on sessionData based on _maxIdleMs of Session which is zero. I
> think this is causing the issue.
>
>
>
>
> --
> View this message in context: http://jetty.4.n6.nabble.com/Jetty-clustering-not-working-properly-jettySessions-expiryTime-getting-set-to-0-after-sometime-tp4958537p4958540.html
> Sent from the Jetty User mailing list archive at Nabble.com.
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Jetty clustering not working properly (jettySessions expiryTime getting set to 0 after sometime)

Jan Bartel-3
Fixed.

Jan

On 29 May 2012 10:41, Jan Bartel <[hidden email]> wrote:

> Venkat,
>
> Thanks for the clear explanation, I raised this bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=380866
>
> Will let you know when its fixed.
>
> Jan
>
> On 29 May 2012 07:59, venkat_99 <[hidden email]> wrote:
>> Here is the config of JDBCSessionManager we are using on both the nodes
>>
>> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>>    <Get name="server">
>>        <Get id="jdbcIdMgr" name="sessionIdManager"/>
>>    </Get>
>>    <Set name="sessionHandler">
>>        <New class="org.eclipse.jetty.server.session.SessionHandler">
>>            <Arg>
>>                <New
>> class="org.eclipse.jetty.server.session.JDBCSessionManager">
>>                    <Set name="idManager">
>>                        <Ref id="jdbcIdMgr"/>
>>                    </Set>
>>                    <Set name="SaveInterval" type="long">-60000</Set>
>>                    <Set name="MaxInactiveInterval" type="int">120</Set>
>>                </New>
>>            </Arg>
>>        </New>
>>    </Set>
>> </Configure>
>>
>> The JDBCSessionIdManager is defined separately in the config file of
>> jetty-7.xml, in our case both the nodes have the maxIdleTime. When I
>> inspected into the methods of access during session migration whenever a
>> session migration happens from one node to other nodes the second
>> constructor of AbstractSession is being called. In this constructor there is
>> no set like below  on the session, due to which session has maxIdleMs.
>> _maxIdleMs=_manager._dftMaxIdleSecs>0?_manager._dftMaxIdleSecs*1000:-1;
>>
>> Where as the access method of JDBCSessionManager$Session is setting
>> exprityTime on sessionData based on _maxIdleMs of Session which is zero. I
>> think this is causing the issue.
>>
>>
>>
>>
>> --
>> View this message in context: http://jetty.4.n6.nabble.com/Jetty-clustering-not-working-properly-jettySessions-expiryTime-getting-set-to-0-after-sometime-tp4958537p4958540.html
>> Sent from the Jetty User mailing list archive at Nabble.com.
>> _______________________________________________
>> jetty-users mailing list
>> [hidden email]
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users