Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 277405 - [performance] do not logout between requests
Summary: [performance] do not logout between requests
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P1 enhancement (vote)
Target Milestone: 3.3   Edit
Assignee: Thomas Ehrnhoefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-21 19:54 EDT by Thomas Ehrnhoefer CLA
Modified: 2009-10-01 17:06 EDT (History)
1 user (show)

See Also:


Attachments
Patch (7.96 KB, patch)
2009-05-26 19:20 EDT, Thomas Ehrnhoefer CLA
no flags Details | Diff
mylyn/context/zip (20.71 KB, application/octet-stream)
2009-05-26 19:20 EDT, Thomas Ehrnhoefer CLA
no flags Details
patch v2 (10.24 KB, patch)
2009-08-20 21:54 EDT, Thomas Ehrnhoefer CLA
no flags Details | Diff
mylyn/context/zip (223.77 KB, application/octet-stream)
2009-08-20 21:54 EDT, Thomas Ehrnhoefer CLA
no flags Details
patch v3 (10.24 KB, patch)
2009-08-21 14:34 EDT, Steffen Pingel CLA
no flags Details | Diff
patch v4 (3.28 KB, patch)
2009-09-29 15:53 EDT, Thomas Ehrnhoefer CLA
no flags Details | Diff
mylyn/context/zip (62.89 KB, application/octet-stream)
2009-09-29 15:53 EDT, Thomas Ehrnhoefer CLA
no flags Details
patch that uses head request (2.38 KB, text/plain)
2009-10-01 16:51 EDT, Steffen Pingel CLA
no flags Details
patch that uses head request (2.38 KB, patch)
2009-10-01 16:52 EDT, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (36.65 KB, application/octet-stream)
2009-10-01 16:52 EDT, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Ehrnhoefer CLA 2009-05-21 19:54:33 EDT
Instead of 
login-request-logout
for each call, just login on startup (and on a lost login). this would save  2 requests and could speed up the connector.
Comment 1 Thomas Ehrnhoefer CLA 2009-05-26 19:20:10 EDT
Created attachment 137242 [details]
Patch

Not sure if this is enough for this task, tests do pass - with some limitation:

I had to tweak the JiraClient Tests because with this change they failed sometimes. 
It seems to be some race condition (for which there already is a very ugly Thread.sleep(500) in the Test. I tried to get rid of it by calling a getIssueByKey instead, but it still kept failing sometimes.
Also, I did some Tests with different setups (network connection as well as with this patch or without), here are the results:

500ms sleep:
no	patch: 0 /35 (WLAN)
no	patch: 0/35 (LAN)
with	patch: 3/35 (WLAN)
with	patch: 6/35 (LAN)

750ms sleep:
with	patch: 0/35 ( LAN)

The numbers being the single assert that could sometimes fail (times failed / times invoked).

The test that fails adds comments to an issue (calling client.updateIssue) and even though I call it twice with 500ms in between (or with a client.getIssueByKey in between) sometimes the second comment shows up as first comment. I do not see why. Any idea Steffen?
Comment 2 Thomas Ehrnhoefer CLA 2009-05-26 19:20:13 EDT
Created attachment 137243 [details]
mylyn/context/zip
Comment 3 Steffen Pingel CLA 2009-05-27 01:02:50 EDT
It's a good start and I have committed the changes. There are still a bunch of things missing though such as handling of authentication failures and test cases. I'll take this bug for now.
Comment 4 Steffen Pingel CLA 2009-06-02 19:44:40 EDT
I have reverted the changes for now (bug 278819).
Comment 5 Thomas Ehrnhoefer CLA 2009-08-20 21:54:12 EDT
Created attachment 145218 [details]
patch v2

There are a couple of things that needed fixing here.
Bug 278819 broke because of missing detection of invalid sessions. This patch now introduces detection (which should, in theory, be a "user not logged in" site) and tries a second time with a login.
In theory, because there is at least one scenario (requesting the XML representaiton of an issue) where the site is gzipped but the HTTP header type is html/text, so a workaround has been added to cover that.
Finally for the test it turns out that the logout does not do a complete logout: after calling logout, calls still worked. A .clear() on the httpclient state fixed that issue.

Steffen, was that what you were talking about in comment 3, or are there other things we need to take care of and other tests necessary?
Comment 6 Thomas Ehrnhoefer CLA 2009-08-20 21:54:16 EDT
Created attachment 145219 [details]
mylyn/context/zip
Comment 7 Steffen Pingel CLA 2009-08-21 14:34:13 EDT
Created attachment 145308 [details]
patch v3

Great stuff! Patch applied with a minor modification: I extracted the method that checks for the authentication exception.
Comment 8 Steffen Pingel CLA 2009-08-21 14:35:38 EDT
Marking resolved.
Comment 9 Steffen Pingel CLA 2009-09-24 20:13:17 EDT
As descried on bug 277254 comment 6-8 there is still a scenario when this is failing: If a user switches networks while being logged in the session may expire and subsequent requests will be processed without being logged in which can have unexpected effects, e.g. query returning the wrong results.

I couldn't find an obvious way to verify that a login session is valid. Thomas, can you investigate if there is a cheap request that we can make prior to each request to validate the session?
Comment 10 Thomas Ehrnhoefer CLA 2009-09-29 14:06:44 EDT
Seems like for now we have enable login vor every request again, see bug 277254 comment 10 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=277254#c10 ) for details
Comment 11 Thomas Ehrnhoefer CLA 2009-09-29 15:53:13 EDT
Created attachment 148362 [details]
patch v4

This patch adds login for every request again. The previously added testcase should make sure this works, since a logout purges all cookies.
Next step is to find out if there is a cheap way to check if we are still logged in.
Comment 12 Thomas Ehrnhoefer CLA 2009-09-29 15:53:18 EDT
Created attachment 148363 [details]
mylyn/context/zip
Comment 13 Steffen Pingel CLA 2009-09-30 00:59:24 EDT
Let me know when you want me to apply the patch.
Comment 14 Thomas Ehrnhoefer CLA 2009-09-30 12:39:48 EDT
well, I do not think there will be time to do the more elegant solution (checking for login), so for now this patch is all I can do I fear.
Comment 15 Steffen Pingel CLA 2009-09-30 15:07:20 EDT
Have you tried a HEAD request for a protected page, e.g. http://mylyn.eclipse.org/jira-enterprise-3.13.5/secure/UpdateUserPreferences!default.jspa ? If you are not logged in that should return a redirect and a 200 otherwise.
Comment 16 Steffen Pingel CLA 2009-10-01 16:51:50 EDT
Created attachment 148584 [details]
patch that uses head request
Comment 17 Steffen Pingel CLA 2009-10-01 16:52:20 EDT
Created attachment 148585 [details]
patch that uses head request
Comment 18 Steffen Pingel CLA 2009-10-01 16:52:23 EDT
Created attachment 148586 [details]
mylyn/context/zip
Comment 19 Steffen Pingel CLA 2009-10-01 16:53:45 EDT
I have committed a change as suggested in comment 15.
Comment 20 Thomas Ehrnhoefer CLA 2009-10-01 17:06:38 EDT
cool stuff, thanks Steffen