Issue 3456: Gerrit Merge Order issue
Status:  New
Owner: ----
Reported by arunjobe...@gmail.com, Jun 25, 2015
*****************************************************************
*****                                                       *****
***** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!!  *****
*****                                                       *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, CYANOGENMOD,  *****
***** INTERNAL ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.*****
*****                                                       *****
*****   THOSE ISSUES BELONG IN DIFFERENT ISSUE TRACKERS     *****
*****                                                       *****
*****************************************************************

Affected Version: Gerrit 2.10

What steps will reproduce the problem?
1. Change 338 is sent for code-review of same file
2. Change 339 is sent for code-review of same file
3. Change 338 got +2 code review value
4. Change 339 got +2 code review value
5. Reviewer clicked on "submit" for change 339
   change is not merged.... since 338 is not yet merged
6. Now, reviewer clicked on "submit" for change 338
   Both the changes are merged automatically.

But the issue is, Gerrit is merging the changes order in a strange way. First 389 is merged and then 338 got merged.

What is the expected output? What do you see instead?
338 should be merged first, not the 339. Please fix this.

Please provide any additional information below.
I am using Gerrit 2.10

gerrit merge order issue.jpg
80.2 KB   View   Download
Jun 25, 2015
Project Member #1 edwin.ke...@gmail.com
 > But the issue is, Gerrit is merging the changes order in a strange way. First 389 
 > is merged and then 338 got merged.

I doubt that Gerrit did this merge in the wrong order. Have you checked the commit graph of your repository?
Status: AwaitingInformation
Jun 26, 2015
#3 arunjobe...@gmail.com
You are correct. When I checked the commit graph, It is in the correct order.

But I dont know why the page "http://ip_address:8080/#/q/status:merged (please see the screen shot attached) is showing the merge order in the wrong order. 

Whenever "submit" button is clicked on gerrit code-review screen, I am calling the hook "change-merged" and in the hook I am using the below command to read all the list of changes got merged. 

GET http://ip_address:8080/changes/?q=status:merged

So, here this page status:merged is getting updated in the wrong order thats why my list is also in the wrong when I am reading them.  How can I read the commits which got merged in the correct order.
Jun 26, 2015
Project Member #4 edwin.ke...@gmail.com
 > But I dont know why the page "http://ip_address:8080/#/q/status:merged (please 
 > see the screen shot attached) is showing the merge order in the wrong order. 
Query results like this are always sorted by last-updated timestamp and not by merge order. It is not possible to choose a different sorting.

 > How can I read the commits which got merged in the correct order.
Use git to fetch the branch and inspect the branch history.
Jun 26, 2015
#6 arunjobe...@gmail.com
> How can I read the commits which got merged in the correct order.
Use git to fetch the branch and inspect the branch history.

I am not sure if I can use git fetch or not. Because, multiple commits come from multiple projects(repositories). For all the projects we are using this Gerrit code review process. All of them must go through code review process. If that is the case, each change could be from different every other.

No matter what projects I get, I am trying to populate the list and trying to connect them with a ticketing system.

I am still confused :(
Jun 26, 2015
Project Member #7 edwin.ke...@gmail.com
Then you should maybe listen to the Gerrit stream-events [1]. This will give you the merged events in the right order.

[1] https://gerrit-review.googlesource.com/Documentation/cmd-stream-events.html
Jun 26, 2015
#8 arunjobe...@gmail.com
Thank you for the link. I think stream events are using ssh, but in my case both git and gerrit are on the same linux box. I am wondering that, I can not ssh to the same box.
Jun 26, 2015
Project Member #9 edwin.ke...@gmail.com
You should be able to connect via SSH to Gerrit from the same machine. Pay attention that Gerrit's SSH daemon by default listens on port 29418. Have a look at [1].

[1] https://gerrit-review.googlesource.com/Documentation/user-upload.html#ssh
Jun 26, 2015
#10 arunjobe...@gmail.com
As the documentation says... I have generated the ssh keys from the box (where actually Gerrit and Git both are residing in the same box) and pasted the keys in Gerrit web interface.

This is like doing the ssh to the same box

and also "change-merged" hook file is obviously on the same box...

however, i tried as the document says to see my luck.. but this is what i am getting .. below is the error:


[gerrituser@gerritbox01 .ssh]$ ssh -p 29418 gerrituser@gerritbox01
Warning: the RSA host key for '[gerritbox01]:29418' differs from the key for the IP address '[##.##.##.##]:29418'
Offending key for IP in /home/gerrituser/.ssh/known_hosts:1
Matching host key in /home/gerrituser/.ssh/known_hosts:2
Are you sure you want to continue connecting (yes/no)? yes
Permission denied (publickey).
[gerrituser@gerritbox01 .ssh]$
Jun 26, 2015
#11 arunjobe...@gmail.com
Also for your information, we are not using ssh to clone/push. we are using http

git clone http://username@##.##.##.##:8080/repository_name


Jul 1, 2015
Project Member #12 edwin.ke...@gmail.com
 > Also for your information, we are not using ssh to clone/push. we are using http

The stream-events are only available over SSH. So if SSH is completely disabled on your Gerrit server, you cannot use them.
Status: New