This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 252189 - Retrieve context from repository loops endless if there was no local task context
Summary: Retrieve context from repository loops endless if there was no local task con...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P2 major with 1 vote (vote)
Target Milestone: 3.1   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-27 10:17 EDT by Jörg Thönnes CLA
Modified: 2009-02-23 12:25 EST (History)
6 users (show)

See Also:


Attachments
fix (9.65 KB, patch)
2008-12-29 23:03 EST, Steffen Pingel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Thönnes CLA 2008-10-27 10:17:32 EDT
Steps to reproduce:

1. Create a trac ticket and attach a Mylyn task context.
2. Switch to another work space.
3. Open the above ticket (using a query) etc.
4. Retrieve task context.
5. Popup: "No local task context exists. Retrieve from repository"
6. Answer: "Yes"
7. Selection dialog to show the list of task context attachments appears
8. Goto step 4

Only way to break out of this loop is to answer "No" if asked whether to retrieve context.

Tried to workaround by creating a dummy task context first.
But this lead to the same behaviour, in addition, the dummy context was cleared.

In the consequence, this disables the retrieve context from Trac for me. Therefore "major"

Would be happy to have any workarounds at least.
Comment 1 Steffen Pingel CLA 2008-10-27 16:40:05 EDT
Thanks for reporting this is problem. It is most likely caused by a failed download. The wizard will reactivate the task when closed which triggers the context check again.
Comment 2 Jörg Thönnes CLA 2008-10-28 04:35:54 EDT
(In reply to comment #1)
> Thanks for reporting this is problem. It is most likely caused by a failed
> download. The wizard will reactivate the task when closed which triggers the
> context check again.

Actually, I experienced this issue already some weeks ago, but did not take the time to report it.
Now, as we moved from the Web template connector to the Trac connector, we want to also use
the context sharing features.

In addition, I found that there is currently no workaround if it happens. So please provide me with
some ideas how I could debug / correct this issue. What do mean by failed download? We connect
locally in our intranet to the trac system.

Of course, I would appreciate if the correction would appear in the "weekly" (not "dev") builds soon.

If you need more input or a TCP level trace / dump to debug, please tell me what you need.

Cheers, Jörg
Comment 3 Steffen Pingel CLA 2008-10-28 15:28:56 EDT
Is there an error in the log? For some reason the context is not found when the task is activated in step 4 triggering a prompt to download the context again. 

So far I have not been able to reproduce this, e.g. with this task: http://mylyn.eclipse.org/tractest/ticket/18 . With version of Trac are you using?
Comment 4 Jörg Thönnes CLA 2008-10-29 06:27:48 EDT
(In reply to comment #3)
> Is there an error in the log? For some reason the context is not found when the
> task is activated in step 4 triggering a prompt to download the context again.

No, I cannot see any error in the log. Just some unrelated errors from groovy and some breakpoint manager.

> So far I have not been able to reproduce this, e.g. with this task:
> http://mylyn.eclipse.org/tractest/ticket/18 . 

That task works as expected.

>With version of Trac are you using?

We use 0.10.4 on a Ubuntu Gutsy or Hardy system as a Debian package.
For the XML_RPC we use plugin version 0.1

If you suspect an error retrieving the task, at least the error handling should be improved.

Comment 5 Jörg Thönnes CLA 2008-11-05 10:01:39 EST
Hi Steffen,

please, could I drag your attention to this bug: How could I find out what the reason for my error is?

Perhaps you could improve the error handling to show any problems on retrieving the context?

Thanks, Jörg
Comment 6 Leif Jonsson CLA 2008-11-06 05:28:12 EST
I am having the same problem after moving a bugzilla backend database to another machine. Having an IP number based addressing scheme, I notice that the new machine has another IP address than the old machine with the bugzilla database and I am wondering if it can have something to do with that, noting that in the "mylyn-context.zip" file, the xml filename seems to be the url of the bugzilla database machine (http%3A%2F%2F147.214.208.36%3A8080-22) in my case.

I unzipped the .xml file an rezipped it with the ip-address changed but this didnt seem to help so maybe it is a bad lead...

I can synchronize the tasks fine, but retrieving the context I get the repeating "No local task context exists. Retrieve from repository".

Mylyn Tasks Core 2.3.2.v20080402-2100
Mylyn Context Core 2.3.2.v20080402-2100
Mylyn IDE UI 2.3.2.v20080402-2100
Mylyn Bugzilla Connector UI 2.3.2.v20080402-2100

I don't see eny errors in the Eclipse Error Log that seems obviously related to this either.

Cheers!
-Leif

Comment 7 Steffen Pingel CLA 2008-11-06 14:01:28 EST
Joerg, Leif, could check if the context file is actually created in the workspace/.metadata/.mylyn/contexts/ folder? Which OS are you using?

The file name is based on the URL of the task repository and task id. Mylyn always uses the url that was entered in the task repository properties which could be different from the actual URL of the repository.
Comment 8 Leif Jonsson CLA 2008-11-07 03:39:05 EST
Hi Steffen, 

First, the bugzilla database is migrated from a Windows 2000 machine to a Windows Vista machine. So right now it is on a Windows Vista machine.

The machine with eclipse/mylyn is the exact same machine in both cases a Suse Linux Enterprise 10 machine. 

In my workspace/.metadata/.mylyn/contexts/ there are only two files activity.xml.zip and local-1.xml.zip. 

I can add that using the bugzilla webinterface I can fecth the attached context file and open it manually. 

Cheers!
-Leif




Comment 9 Steffen Pingel CLA 2008-11-07 13:35:50 EST
Leif, can you check the permissions of the context folder on the new machine? Is it writeable by the user running Eclipse?
Comment 10 Jörg Thönnes CLA 2008-11-08 08:34:42 EST
OK, I did download the Mylyn context manually and found that its name is:

http%3A%2F%2Ftsystem%2Ftrac%2FGlox7-67.xml

which refers to the URL "http://tsystem/trac/Glox7-67.xml"
The Id attribute stored in this XML file is also "Id="http://tsystem/trac/Glox7-67".

But the URL "http://tsystem/trac/Glox7" refers to the old name of the trac installation.
Meanwhile, we have renamed it to "http://trac/trac/development", while "http://tsystem/trac/development"
would also work.

In principal, some people could have the tsystem URL in their repository configuration, others the trac URL.

If the different URLs can cause the context loading to fail, I still wonder why no error message is displayed.
Moreover, if I try to load a context and the loading fails, my previous context is also cleared.

From home, I access the Trac repository from a slightly different URL with another port. This would also lead to a
different context name.

If this is the cause of all these issues, do you see anyway to use another mechanism or ask the user if he wants
to relocative the alien context to match the current path?
Comment 11 Jörg Thönnes CLA 2008-11-08 08:59:02 EST
Now I did some experiments:

1. Renamed only the Id inside the XML files and attached the context with the description "mylyn/context/zip"
--> same result
2. Additionally renamed the name of the XML file to match the repository URL
--> this worked
3. Did not try to just rename the file while leaving the Id alone.

As I said previously, I sometimes the repository from a different URL (at least different port). Also some
people access it as "tsystem", others as "trac" (both the same IP). Therefore, chances are big to get more
such errors.

Now I wonder why the repository ID is so tightly coupled with the host and port?

Options are:
 - Make the repository ID configurable, suggest the current scheme as default
 - Allow to migrate alien contexts (let the user choose whether he want to ignore the different URL)

What do you think? Could this restriction relaxed at bit quit soon since this prevented us from using the
context attachments at all?
Comment 12 Steffen Pingel CLA 2008-11-08 15:22:09 EST
Thanks for analyzing the bug Joerg! Using the full handle which includes the repository url in the context zip file can indeed break sharing of contexts when different urls are used to access the repository. In addition the code should be made robust to validate the file when it is downloaded to inform the user of any failures.

Mik, what are your thoughts on this?
Comment 13 Jörg Thönnes CLA 2008-11-10 09:41:24 EST
I would suggest the following steps / options.

1. Provide a check / error message to alert the user.
2. Extend 1. to allow the user to accept that differing URL and apply the context anyway.
3. Provide a configuration dialog (per repository) to add task URL aliases.

Point 3. is motivated by my use case, that I access the trac repo using a different host/port combination because I have to go over a SSH tunnel from home.

I would really appreciate if points 1. (and 2.) could be implemented rather soon.
Comment 14 Leif Jonsson CLA 2008-11-12 03:18:51 EST
Hi Steffen, 

You say "Using the full handle which includes the
repository url in the context zip file can indeed break sharing of contexts
when different urls are used to access the repository." does this in some way imply that there is some kind of workaround that me and Jörg can use until this bug is resolved? Can we configure our systems in some way to not use "full handle" and get it to work temporarily?

Cheers!
-Leif
Comment 15 Steffen Pingel CLA 2008-11-12 03:23:20 EST
Sorry, I can't think of a workaround other than manually renaming the file in the zip which is not practical. The fact that Mylyn uses the full handle is an internal implementation detail which probably needs to be changed to fix this bug. I'll raise this on Thursday's conference call.
Comment 16 Leif Jonsson CLA 2008-11-12 03:29:08 EST
I see! Thanks for the quick reply!

Cheers!
-Leif
Comment 17 Jörg Thönnes CLA 2008-11-17 07:38:50 EST
(In reply to comment #15)
> [...] The fact that Mylyn uses the full handle is an
> internal implementation detail which probably needs to be changed to fix this
> bug. I'll raise this on Thursday's conference call.

Steffen, what is the outcome of raising this issue in the last conference call?
What are the next steps?

Thanks, Jörg
Comment 18 Steffen Pingel CLA 2008-11-17 14:55:31 EST
The discussion on the call indicated that the current implementation is expected to handle the case correctly where a context is accessed with a different url but there appears to be a bug in the code. Shawn, will you have to time to look into fixing this?
Comment 19 Shawn Minto CLA 2008-11-17 15:37:26 EST
I can have a look into this later this week.
Comment 20 Shawn Minto CLA 2008-11-18 19:11:37 EST
It looks like this broke between 2.0.0 and 2.1.0.  Right now, it tries to match the name of the internal entry in zip with the handle of the task that is trying to be loaded.  This means that if the context file in the zip file does not have the same identifier, it will not get loaded (as this bug describes).  This seems to have been added as a part of some import/export functionality.  Mik, Steffen, what would the desired fall back be in this scenario?  One potential solution:

* try to find perfect match
* if one exists, use it
* if one doesn't exist, try to make based on task id from the handle
 
Or should we go with a simpler (or more complicated) solution?
Comment 21 Steffen Pingel CLA 2008-11-19 13:14:56 EST
The code in SaxContextReader should fall back to something that is similar to LocalContextStore.getFirstContextHandle(). Ideally there would only be a single implementation.
Comment 22 Steffen Pingel CLA 2008-12-19 21:05:29 EST
Shawn, I'll try to take a pass at fixing this in the next few days.
Comment 23 Shawn Minto CLA 2008-12-22 12:47:55 EST
Thanks Steffen, I havent been able to get time to look into this and don't know if I will before the new year.
Comment 24 Michel Parisien CLA 2008-12-26 17:12:33 EST
(In reply to comment #22)
> Shawn, I'll try to take a pass at fixing this in the next few days.
> 

I also have the same problem, and if you need any help from a user experiencing it, let me know.
Comment 25 Steffen Pingel CLA 2008-12-29 23:03:33 EST
Created attachment 121323 [details]
fix
Comment 26 Steffen Pingel CLA 2008-12-29 23:04:33 EST
I have committed the attached patch. Shawn, can you review? 
Comment 27 Jörg Thönnes CLA 2008-12-30 03:51:11 EST
Cool. I am looking forward to see this in the next weekly build.
Will this be this week?

Thanks, Jörg
Comment 28 Shawn Minto CLA 2008-12-30 11:50:38 EST
Steffen, thanks for getting to this.  The patch looks right to me.  One thing I was wondering was whether we should be looking for the current contexts handle, and if we cant find it, then use the first context handle in the zip?  This would ensure that if a zip had multiple contexts, it would choose the right one if it exists in the file.  This would complicate the code a bit more and may not be needed.  What do you think?
Comment 29 Steffen Pingel CLA 2008-12-30 19:23:32 EST
I have triggered a build, it should be available from the weekly update site in a few hours.

The code should check for a perfect match first and then fall back to the first context handle (the first call to readContext() retuns null in that case).
Comment 30 Shawn Minto CLA 2008-12-30 19:43:23 EST
Right, I see that now.  Sorry I missed that.
Comment 31 Steffen Pingel CLA 2009-01-06 00:29:47 EST
I am marking this bug resolved. Please reopen if you still experience the problem with weekly builds >=I20081231-0000.