Replication of deleted branches

559 views
Skip to first unread message

Luciano Carvalho

unread,
May 26, 2010, 2:17:55 PM5/26/10
to Repo and Gerrit Discussion
I have a project owner who started a new branch off of a wrong commit for 7 of his projects.

To fix it, he went to Gerrit's web-ui and deleted the branch for those projects, then created another one (using the ui) with the same name but based on the correct commit this time.

After he did it, non-fast-forward errors started to pop in the error-log for those 7 projects.

To fix it, I had to delete the branches in all the mirrors, then force the replication again.

Questions: 
- do branch deletions get replicated?
- is this approach of deleting/creating branches through web-ui (non-)recommended?
- (I didn't test it) If I delete a branch through "git push origin :branch", does this deletion gets replicated?


Just trying to understand if there is a bug in the replication.

My thoughts: yes, it is a bug. Because it is not replicating an action taken in the repo.

Regards,

Luciano.


Shawn Pearce

unread,
May 26, 2010, 2:35:20 PM5/26/10
to Luciano Carvalho, Repo and Gerrit Discussion
On Wed, May 26, 2010 at 11:17, Luciano Carvalho <lsca...@gmail.com> wrote:
> I have a project owner who started a new branch off of a wrong commit for 7
> of his projects.
> To fix it, he went to Gerrit's web-ui and deleted the branch for those
> projects, then created another one (using the ui) with the same name but
> based on the correct commit this time.
> After he did it, non-fast-forward errors started to pop in the error-log for
> those 7 projects.

The replication queue coalesces edits together according to the
replication delay. The default delay IIRC is 30 seconds. So if you
delete a branch and then create it again within 30 seconds that will
coalesce together to simply pushing that branch. Unfortunately its
not recorded as needing to be a force-push. So unless your
replication.config specifies force push on the branch, the push will
fail with a non-fast-forward error.

> To fix it, I had to delete the branches in all the mirrors, then force the
> replication again.

Yes. Sounds like your replication.config didn't specify force push.

> Questions:
> - do branch deletions get replicated?

Yes, like any other change.

> - is this approach of deleting/creating branches through web-ui
> (non-)recommended?

Its fine. It just can cause an issue here with the replication. :-\

A better way to reset a branch would have been to force push it... but
that still would have failed in replication because its sounds like
your replication.config doesn't force push to the remotes.

> - (I didn't test it) If I delete a branch through "git push origin :branch",
> does this deletion gets replicated?

Yes.

> Just trying to understand if there is a bug in the replication.
> My thoughts: yes, it is a bug. Because it is not replicating an action taken
> in the repo.

I'm not sure I would call this a bug. Your replication.config should
be configured to force-push to the remote if the remote is willing to
accept a force push. If the remote absolutely should not get rewound,
then its correct to have replication fail, as it indicates the remote
is out-of-sync with the local Gerrit server.

However, maybe there is a bug here that a rapid delete-create sequence
within the replication delay window isn't actually mirrored as a
delete-create sequence to the remote, but instead got coalesced into
an update. Perhaps we should instead recognize a delete-create
sequence and actually issue that same delete-create on the remote.

Luciano Carvalho

unread,
May 26, 2010, 4:18:39 PM5/26/10
to Shawn Pearce, Repo and Gerrit Discussion
Hi Shawn,

I didn't find instruction on how to make the replication to force push in the documentation.

Help, please.

Thanks,

Luciano

Shawn Pearce

unread,
May 26, 2010, 4:45:18 PM5/26/10
to Luciano Carvalho, Repo and Gerrit Discussion
Luciano Carvalho <lsca...@gmail.com> wrote:
> I didn't find instruction on how to make the replication to force push in
> the documentation.

Wow, its really not documented.

I assumed you could look this up in the official git docs, like in
git-push [1], because the remote format is the same. Unfortunately
that document doesn't really explain it either!

To configure force-push, add a "+" to the start of the push refspec
you want to enable force-push on. E.g.

[remote "mirror"]
url = mirror1:${project}
push = +refs/heads/master
push = +refs/heads/experimental
push = refs/heads/stable

Will permit force-push on the first two branches (master,
experimental) but not on stable.

If the push variable is not specified in a remote, Gerrit defaults to
"+refs/*:refs/*" so that force push is enabled on all refs [2].

[1] http://www.kernel.org/pub/software/scm/git/docs/git-push.html
[2] http://gerrit.googlecode.com/svn/documentation/2.1.2/config-replication.html#remote.name.push

Luciano Carvalho

unread,
May 26, 2010, 5:11:29 PM5/26/10
to Shawn Pearce, Repo and Gerrit Discussion
If force push is default, then I shouldn't be getting those non-fast-forward errors, should I?

Quoting your statement earlier in the thread: "So unless your
replication.config specifies force push on the branch, the push will
fail with a non-fast-forward error."

Shawn Pearce

unread,
May 26, 2010, 5:18:02 PM5/26/10
to Luciano Carvalho, Repo and Gerrit Discussion
Luciano Carvalho <lsca...@gmail.com> wrote:
> If force push is default, then I shouldn't be getting those non-fast-forward
> errors, should I?

Correct.

> Quoting your statement earlier in the thread: *"**So unless your*
> *replication.config specifies force push on the branch, the push will
> *
> *fail with a non-fast-forward error.**"*

Right. So if you don't mention the push variable in the relevant
remote section of your replication.config, its a bug that we didn't
replicate the change.

What was the exact error in your error_log?

Luciano Carvalho

unread,
May 26, 2010, 5:35:20 PM5/26/10
to Shawn Pearce, Repo and Gerrit Discussion


[2010-05-25 08:15:58,305] ERROR com.google.gerrit.server.git.PushReplication : Failed replicate of refs/heads/branch to user@server:/android/platform/build.git, reason: non-fast-forward
[2010-05-25 08:34:45,925] ERROR com.google.gerrit.server.git.PushReplication : Failed replicate of refs/heads/branch to user@server:/android/platform/bootable/diskinstaller.git, reason: non-fast-forward

Shawn Pearce

unread,
May 27, 2010, 4:19:18 PM5/27/10
to Luciano Carvalho, Repo and Gerrit Discussion
Luciano Carvalho <lsca...@gmail.com> wrote:
> [2010-05-25 08:15:58,305] ERROR com.google.gerrit.server.git.PushReplication
> : Failed replicate of refs/heads/branch to
> user@server:/android/platform/build.git,
> reason: non-fast-forward
> [2010-05-25 08:34:45,925] ERROR com.google.gerrit.server.git.PushReplication
> : Failed replicate of refs/heads/branch to
> user@server:/android/platform/bootable/diskinstaller.git,
> reason: non-fast-forward

These errors are because Gerrit tried to do the non-fast-forward
push, but the destination Git has receive.denyNonFastForwards set
to true in its configuration file for the repository, so the remote
server is rejecting the push.

Luciano Carvalho

unread,
May 27, 2010, 6:27:06 PM5/27/10
to Shawn Pearce, Repo and Gerrit Discussion
got it now... 
I'll change the configuration to try to avoid this in the future.

Thanks
Reply all
Reply to author
Forward
0 new messages