Issue 755: Receive stream-event for new patchset before it is available
Status:  Released
Owner: ----
Closed:  May 2011

Blocking:
issue 779
Project Member Reported by bklarson@gmail.com, Oct 15, 2010
Affected Version: 2.1.5-73-g7f243d5 (r.android.com)

What steps will reproduce the problem?
1. Listen to the Gerrit stream-events feed
2. When a patchset-added event is received, try to repo download the patchset immediately
3. Notice that repo can't find the patchset

What is the expected output? What do you see instead?
Expect the patchset to be downloaded.  Instead I get:

fatal: Couldn't find remote ref refs/changes/AB/CDEFG/1
[tools/gerrit] change CDEFG/1 not found


Please provide any additional information below.

Adding a 'sleep 30' command to the start of the script, before running repo download, solves this problem.  This isn't needed on our internal server (still running 2.1.2.3), but it might be due to server load, network latency, etc.
Nov 18, 2010
Project Member #1 bklarson@gmail.com
As a follow up, sleep 30 isn't always sufficient.  I've had to up it to 120, and sometimes the change still isn't available.  Sleeping definitely helps though.
Dec 13, 2010
Project Member #2 fredrik....@sonyericsson.com
It is probable that this comes from replication delay. Every time something is uploaded to a master gerrit server, a timer starts, waiting for 15 or 30 seconds (I never quite remember which) before syncing the git to the replicated locations (usually slave gerrit servers, but sometimes for instance android.git.kernel.org as well..). If a new push arrives to the git within those 15/30s, the timer is resetted again (IIRC..). 
So, with bad luck, it'll take a while before the change actually make it to the replication locations. 

My best tip would be to have a function around repo download that retries in case of failure / verifies existence of the change before commencing the download.
May 19, 2011
Project Member #3 nas...@grainawi.org
@bklarson, are you fetching directly from the Gerrit server or via a mirror that's being replicated to?
May 19, 2011
Project Member #4 nas...@grainawi.org
(No comment was entered for this change.)
Blocking: 779
May 20, 2011
#5 sop@google.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.1.7
May 20, 2011
Project Member #6 bklarson@gmail.com
@nasser, I believe I saw this when monitoring r.android.com for my gerrit+hudson(jenkins) gittogether demo last year.  I can't remember how that server uses replication, but in any case it sounds like Shawn has this fixed (Thanks Shawn!!)
May 20, 2011
#7 sop@google.com
r.android.com can have as much as a  6 minute replication delay... on a good day when everything is working well. Some days its longer.  :-(
May 31, 2011
#8 sop@google.com
(No comment was entered for this change.)
Status: Released