Bug 164964 - FAQ [CVSNT] CVS compare is comparing with wrong revision
Summary: FAQ [CVSNT] CVS compare is comparing with wrong revision
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: CVS (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.3 M6   Edit
Assignee: platform-cvs-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: faq
: 164961 164962 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-17 09:35 EST by Willian Mitsuda CLA
Modified: 2007-03-19 08:19 EDT (History)
0 users

See Also:


Attachments
Screenshot of compare editor (156.35 KB, image/gif)
2006-11-17 09:39 EST, Willian Mitsuda CLA
no flags Details
Screenshot of compare editor (156.35 KB, image/gif)
2006-11-17 09:41 EST, Willian Mitsuda CLA
no flags Details
Screenshot of compare editor (156.35 KB, image/gif)
2006-11-17 09:43 EST, Willian Mitsuda CLA
no flags Details
Screenshot of the cache error (52.87 KB, image/gif)
2006-12-13 12:44 EST, Willian Mitsuda CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Willian Mitsuda CLA 2006-11-17 09:35:19 EST
I begin to see this bug some weeks ago.

What happens: I synchronize, it shows some outgoing changes, I double-click the file on synchronize view.

It opens the compare editor, but in remote pane, it compares against a wrong revision (it appears to be always the revision on HEAD), instead of the current revision.

Apparently the other operations (commit, etc...) work fine, it appears to be only a "wrong revision on compare" problem.

Some characteristics from my environment that I hope can help to track this issue:

- My server is a CVSNT 2.5.01.
- There are a lot of projects on repository (>50).
- There are many branches created.
- There are some branch of branch created.
Comment 1 Willian Mitsuda CLA 2006-11-17 09:39:41 EST
Created attachment 54072 [details]
Screenshot of compare editor
Comment 2 Willian Mitsuda CLA 2006-11-17 09:41:44 EST
Created attachment 54073 [details]
Screenshot of compare editor
Comment 3 Willian Mitsuda CLA 2006-11-17 09:43:44 EST
Created attachment 54074 [details]
Screenshot of compare editor
Comment 4 Willian Mitsuda CLA 2006-11-17 09:47:55 EST
More information: since I begin to note this bug, I have seem sometimes in the remote pane a message like "There is no cached contents for this... <I don't remember the remaining of message>".

Double-clicking the file again on synchronize view appears to fix this problem.

I'm not sure is this is somewhat related...
Comment 5 Michael Valenta CLA 2006-11-20 09:23:16 EST
*** Bug 164961 has been marked as a duplicate of this bug. ***
Comment 6 Michael Valenta CLA 2006-11-20 09:23:36 EST
*** Bug 164962 has been marked as a duplicate of this bug. ***
Comment 7 Michael Valenta CLA 2006-12-12 14:46:59 EST
Looks like a dup of bug 163949. If you're not working on a partial branch (i.e. parts of the local project on different branches), then please let us know.

*** This bug has been marked as a duplicate of bug 163949 ***
Comment 8 Willian Mitsuda CLA 2006-12-12 15:05:19 EST
(In reply to comment #7)
> Looks like a dup of bug 163949. If you're not working on a partial branch (i.e.
> parts of the local project on different branches), then please let us know.

Michael, I'm not working on partial branches.

My branches are all based on entire projects.
Comment 9 Willian Mitsuda CLA 2006-12-12 15:06:12 EST
Apparently it is not a dup of bug#163949.

Should I reopen?
Comment 10 Michael Valenta CLA 2006-12-12 15:36:56 EST
Reopening (although probably still related, does not appear to be an exact duplicate).
Comment 11 Willian Mitsuda CLA 2006-12-13 12:44:08 EST
Created attachment 55599 [details]
Screenshot of the cache error

This is a screenshot of the situation I mentioned on comment#4.

I'm inside a branch, where revision 1.3 is the latest (with modifications).

I synchronized, and after double-clicking it, it attempts to compare with revision 1.9 (the latest of HEAD) and shows that message.

After I close this compare editor, and reopen, it does not presents the message, but presents the compare editor of 1.3 against 1.9.
Comment 12 Willian Mitsuda CLA 2006-12-13 12:47:03 EST
Michael, this is happening in many machines here, with different projects/branches.

I'm willing to help you with this, since this is preventing us to use the compare feature we use extensively.

Can you point me where in the source code this bug can be? Then I can try to reproduce in a debug session.
Comment 13 Michael Valenta CLA 2006-12-13 15:18:20 EST
In regards to the failure to cache, it is odd given that we explicitly fetch the contents beforehand. It sounds like the cache has a bug where it says it has the contents cached before the compare editor opens and then somehow looses the contents when the compare editor is shown. I suspect the problem is related to the timeout we have for cached contents (i.e. perhaps we don't purge the cache properly and thus leave it in a bad state that gets cleared the first time you open the compare editor). This seems to be a separate issue that is less important the original issue (i.e. it is clear that something is wrong and reopening the editor fixes the problem). Could you open a separate bug report for this?

In regards to the original issue, there are a couple avenues to explore here:

1) You could trace the client/server communication involved with the Synchronization to see what is passed. Here's a link on how to do that:

http://wiki.eclipse.org/index.php/CVS_FAQ#Is_there_any_equivalent_to_CVS_CLIENT_LOG_is_Eclipse.3F

2) I noticed in the screenshot that you were using change sets. Does the problem happen when using a different model (e.g. Workspace or Java)?

3) Does the problem occur with the old Sync? I suspect it doesn't but it is good to confirm. See the following link for a description of what I mean by "Old Sync".

http://wiki.eclipse.org/index.php/CVS_FAQ#Synchronizing_has_some_regressions_in_Eclipse_3.2._Why.3F

4) As for source code, I would need to know the answer to question 2 and 3 before I can pinpoint a good location to debug the problem.
Comment 14 Willian Mitsuda CLA 2006-12-13 16:26:17 EST
(In reply to comment #13)
> 1) You could trace the client/server communication involved with the
> Synchronization to see what is passed. Here's a link on how to do that:
> 

I'll try.

> 2) I noticed in the screenshot that you were using change sets. Does the
> problem happen when using a different model (e.g. Workspace or Java)?

In my machine I'm using change sets with Mylar, but there are other machines using just the default team/CVS configuration, because they use Eclipse only as a CVS client for other IDEs.

> 3) Does the problem occur with the old Sync? I suspect it doesn't but it is
> good to confirm. See the following link for a description of what I mean by
> "Old Sync".
> 

Yes, I made some tests and apparently it is a problem with the new model-based synchronization.

I just turned off "Allow models to participate in Synchronizations", dropped all synchronizations, restarted Eclipse. I did this on 3 machines and apparently it worked. But we'll continue to observe if this happens with this option turned off.
Comment 15 Willian Mitsuda CLA 2006-12-13 16:31:05 EST
(In reply to comment #13)
> This seems to be a separate issue that is
> less important the original issue (i.e. it is clear that something is wrong and
> reopening the editor fixes the problem). Could you open a separate bug report
> for this?

Done. See bug#167964.
Comment 16 Willian Mitsuda CLA 2006-12-13 16:59:50 EST
(In reply to comment #13)
> 1) You could trace the client/server communication involved with the
> Synchronization to see what is passed. Here's a link on how to do that:

Good news, tracing the communication, I see that when model-based synchronization is on, there is a explicit get to the HEAD revision when double-clicking the file to open the compare editor:

CMD> cvs update -r "1.9" -C -d -P "<file-name>"

With the model-based off, it get the right revision.

If you want to see the full communication trace, I can send it to you in private.
Comment 17 Michael Valenta CLA 2006-12-13 19:33:27 EST
The question is, where did it get that revision. Does the entry in the sync view show the proper revision?
Comment 18 Willian Mitsuda CLA 2006-12-14 08:42:37 EST
(In reply to comment #17)
> The question is, where did it get that revision. Does the entry in the sync
> view show the proper revision?
> 

Yes, it shows <resource name> - 1.3.2.1 - 1.3.2.1, where 1.3.2.1 is the latest revision from branch, and on compare editor it shows 1.3.2.1 on left pane and 1.9 on right pane, where 1.9 is the latest from HEAD.
Comment 19 Willian Mitsuda CLA 2006-12-18 09:02:39 EST
Michael, if you need more information and/or make some test, feel free to ask me.
Comment 20 Michael Valenta CLA 2007-01-15 11:33:06 EST
Unfortunately, I am still not able to reproduce this. I assume that the fact that there is a workaround makes this less critical. However, if someone who is experiencing this wanted to debug it, the first place to look would be in the ResourceSaveableComparison$ResourceDiffCompareInput#getRightContributor (in the 3.2 codebase). This is the code that determines what revision is used for the right side of the comparison. In 3.3, ResourceDiffCompareInput is root level class (i.e. not internal to ResourceSaveableComparison).
Comment 21 Willian Mitsuda CLA 2007-02-26 13:27:39 EST
Update: I'm debugging now, and it is getting to line 107: "diff = (IResourceDiff)twd.getLocalChange();".

Examining "diff.getBeforeState()" returns a CVSResourceVariantFileRevision, whose variant.syncBytes field contains a "1.9" string encoded, which corresponds to the HEAD revision.

So I'm assuming the bug occurs before this method and I'll go up. Let me know if there are other interesting places to see.
Comment 22 Willian Mitsuda CLA 2007-02-26 14:54:41 EST
I tracked changes on difftree and apparently the only thing that is changing across compare openings is the syncBytes value from RemoteFile.

I tracked the changes to this field and I found a suspicious code at line 403:

// Make sure the sync bytes match the content that is being accessed
syncBytes = newSyncBytes;

I found on case where the actual contents of syncBytes with revision 1.3.2.1 from branch is being replaced with another array from cache, with the value "1.9" on revision.
Comment 23 Michael Valenta CLA 2007-02-26 16:13:11 EST
The real question is where are the wrong sync bytes coming from? Here is a link to instructions on getting a client/server communications trace:

http://wiki.eclipse.org/index.php/CVS_FAQ#Is_there_any_equivalent_to_CVS_CLIENT_LOG_is_Eclipse.3F

It should reveal exactly what Eclipse is sending to the server and what the server is sending back. This may help determine where the 1.9 is coming from.
Comment 24 Willian Mitsuda CLA 2007-02-26 17:22:55 EST
It appears to be coming from the server, on what looks like to be the lastest command executed after synchronization.

Following is the snippet of the latest part of traffic, where I substituted the problematic file name by "xxxx.cpp", and the cvs path by "/repository/myproject". The HEAD revision is 1.9 and the branch revision is 1.3.2.1.

CMD> cvs update -C -d -P "xxxx.cpp"
Argument -C
Argument -d
Argument -P
Directory .
/repository/myproject
Sticky TR1_4_1
Entry /xxxx.cpp/1.3.2.1///T1.3.2.1
Modified xxxx.cpp
u=rw,g=rw,o=r
0
Argument xxxx.cpp
Directory .
/repository/myproject
update
MT +updated
MT text U 
MT fname xxxx.cpp
MT newline
MT -updated
Update-existing ./
/repository/myproject/xxxx.cpp
/xxxx.cpp/1.9//-kkv/
u=rw,g=r,o=r
66004
ok
RESULT> Status OK: org.eclipse.team.cvs.core code=0 ok null
Comment 25 Michael Valenta CLA 2007-02-27 09:19:25 EST
Here's the trace I get using CVSNT 2.5.03 which is what is expected. Have you configured the server as described here:

http://wiki.eclipse.org/index.php/CVS_FAQ#How_do_I_configure_CVSNT_to_work_with_Eclipse.3F

Anyway, I can't see any difference in the trace that would indicate why your case would behave differently. From this, I can only conclude that the cause of this is a bug in CVSNT.

CMD> cvs update -C -d -P "my.properties"
Argument -C
Argument -d
Argument -P
Directory .
/cvs/repo/MyJavaProject
Sticky Tbranch_20070112
Entry /my.properties/1.1.2.1///T1.1.2.1
Modified my.properties
u=rw,g=rw,o=r
0
Argument my.properties
Directory .
/cvs/repo/MyJavaProject
update
MT +updated
MT text U 
MT fname my.properties
MT newline
MT -updated
Update-existing ./
/cvs/repo/MyJavaProject/my.properties
/my.properties/1.1.2.1//-kkv/T1.1.2.1
u=rw,g=rw,o=rw
16
ok
Comment 26 Willian Mitsuda CLA 2007-02-27 13:01:19 EST
I did some tests here with a test installation, and finally got the steps to reproduce:

- Install CVSNT 2.5.01.
- Create a new Java project and share it with your repository.
- Create a class. Commit and tag with R1_0_0.
- Modify this class. Commit and tag with R2_0_0.
- Replace with version R1_0_0. Create a branch from this version, and start working on branch.
- Make some modification on the class. Commit. This will create revision 1.1.2.1.
- Make some modification. Synchronize.
- The class will appear on synchronize view. Double-click to open compare.
- It will compare against revision 1.2 (HEAD) instead of 1.1.2.1.

I'll test with 2.5.02 and 2.5.03 and see if something changed. And yes, it is configured according the instructions.
Comment 27 Willian Mitsuda CLA 2007-02-27 14:17:55 EST
That is funny. I just tested with a 2.5.03 installation and it works perfectly.

I wasn't able to test with 2.5.02 because I didn't find it on CVSNT site:

http://www.cvsnt.org/archive/

Also, I wasn't able to find any changelog on (confusing) CVSNT website to confirm if this was some fixed bug.

What I don't know yet is why it doesn't happen on old synchronization mode.
Comment 28 Willian Mitsuda CLA 2007-02-27 14:38:52 EST
(In reply to comment #27)
> What I don't know yet is why it doesn't happen on old synchronization mode.
> 

Also, one thing I noted is that when you disable "Allow models to participate on synchronizations" you have to restart Eclipse, instead of just dropping the synchronization and recreating it, for this workaround to work. Is this considered a bug?
Comment 29 Michael Valenta CLA 2007-02-27 14:51:40 EST
I'm not sure what you mean. Could you elaborate on what you tried before restarting Eclipse? The old Synchronization will stay in the view unless it is specifically removed (there's a remove in the view menu). Is this what you mean?
Comment 30 Willian Mitsuda CLA 2007-02-27 15:29:01 EST
(In reply to comment #29)
> I'm not sure what you mean. Could you elaborate on what you tried before
> restarting Eclipse? The old Synchronization will stay in the view unless it is
> specifically removed (there's a remove in the view menu). Is this what you
> mean?
> 

I'm talking about the workaround, which is to disable the model-based synchronization.

I was testing this bug with new model synchronization and I wanted to revert it to the old behavior.

So, I unchecked the box "Allow models to participate on synchronizations" on CVS synchronization preferences, accessing it through the "Synchronization" view menu.

I dropped the synchronization (the "X" on view menu), and synchronized again. But it was not enough, because the compare editor on the new synchronization contents still presented the bug (although the model-based sync is disabled because the model drop-down does not appears on view toolbar).

Perhaps something to do with the cache...

On this case I have to restart Eclipse for the synchronization to work.
Comment 31 Michael Valenta CLA 2007-02-27 15:45:43 EST
So what you are saying is that you did revert to the old behavior but the "bug" didn't go away until you restarted Eclipse. The underlying data for the two sync types is the same so what you say is possible. However, the data is persisted across restarts as well so I'm not sure why a restart would make a difference. I'm not sure if it is worth pursuing that at this time. I am more interested in the original problem. Are you saying that the problem does not occur in the latest CVSNT build?
Comment 32 Willian Mitsuda CLA 2007-02-27 15:53:46 EST
(In reply to comment #31)
> So what you are saying is that you did revert to the old behavior but the "bug"
> didn't go away until you restarted Eclipse. The underlying data for the two
> sync types is the same so what you say is possible. However, the data is
> persisted across restarts as well so I'm not sure why a restart would make a
> difference. I'm not sure if it is worth pursuing that at this time.

Yes, I suspect it is some "side-effect" of the original bug + some other unknown cache bug.

> I am more
> interested in the original problem. Are you saying that the problem does not
> occur in the latest CVSNT build?
> 

Yes, it does not happen on 2.5.03.
Comment 33 Michael Valenta CLA 2007-03-12 14:16:10 EDT
The problem was caused by a bug in the CVSNT server.
Comment 34 Willian Mitsuda CLA 2007-03-12 15:22:35 EDT
Michael, I understand that it is not worth to make "workarounds" on Eclipse side just because of CVSNT faults, so I think the recommendation on this page:

http://wiki.eclipse.org/index.php/CVS_FAQ#What_server_versions_of_CVS_are_supported_by_Eclipse.3F

is not entirely true anymore.

I'd like to know what version is officially "supported", and by "supported" I mean: the version used on your tests. 2.5.03?
Comment 35 Michael Valenta CLA 2007-03-12 15:39:04 EDT
We do not test against CVSNT at all. CVSNT was promoted to supported because the main CVSNT developer made an effort to address several incompatibilities between CVS and CVSNT. Since we do not use CVSNT ourselves, we rely on the community to ensure that compatibility is maintained.

I will update the support version number for CVSNT on the FAQ (although you could do it yourself if you like since anyone who can comment in bugzilla can update the FAQ).
Comment 36 Willian Mitsuda CLA 2007-03-17 10:30:38 EDT
I added a note to http://wiki.eclipse.org/index.php/CVS_FAQ#What_server_versions_of_CVS_are_supported_by_Eclipse.3F section pointing to this bug.
Comment 37 Michael Valenta CLA 2007-03-19 08:19:48 EDT
Thanks.