Copying submitted MR from One Gerrit Server to another

119 views
Skip to first unread message

ishan badgainya

unread,
Jan 28, 2025, 1:48:26 AM1/28/25
to Repo and Gerrit Discussion
Hi all,
I have two Gerrit servers - 
1. Client's Gerrit
2. My Gerrit

I can copy the code to my Gerrit using repo sync and git push but the respective Submitted MRs don't come. Is there a way to copy these MRs also? 

Sven Selberg

unread,
Jan 28, 2025, 4:25:11 AM1/28/25
to Repo and Gerrit Discussion
This data lives in the `refs/changes/.*` namespace, so you'll need to fetch those refs also and apply to "your" Gerrit.
https://gerrit-review.googlesource.com/Documentation/note-db.html
 

Sven Selberg

unread,
Jan 28, 2025, 4:27:41 AM1/28/25
to Repo and Gerrit Discussion
But IIRC you will not be able to push those refs (i.e. I think you'll need to apply them on disk and bypass Gerrit), and if you just push them and I don't know if index and caches on "your" Gerrit will be updated correctly out-of-the-box.
 

 

ishan badgainya

unread,
Jan 28, 2025, 7:08:26 AM1/28/25
to Repo and Gerrit Discussion
Hi Sven,
Thanks for the info!
I tried the following approach before I saw your reply.

git clone --mirror <client gerrit>
git push --mirror <my gerrit> -o notedb=allow
Gerrit stop , reindex, Gerrit start

I was able to push everything including the refs/changes to my Gerrit.

But here is the problem that I faced:
Let's say the change was in Open state on Client Gerrit when I initially copied it to my Gerrit using above command. On my Gerrit this change is in Open state.
After that the client submits that Change and now, I want to bring this new updated Change again.

If I do git fetch --all <client gerrit> and do a push again to my Gerrit it says "(Cannot create ref 'refs/changes/xxxxxxx' because it already exists.)" which is understandable.

Is it not possible to just update refs/changes? 
Is there any workaround on this? 

Sven Selberg

unread,
Jan 28, 2025, 9:14:40 AM1/28/25
to Repo and Gerrit Discussion
On Tuesday, January 28, 2025 at 1:08:26 PM UTC+1 ishan badgainya wrote:
Hi Sven,
Thanks for the info!
I tried the following approach before I saw your reply.

git clone --mirror <client gerrit>
git push --mirror <my gerrit> -o notedb=allow
Gerrit stop , reindex, Gerrit start

I was able to push everything including the refs/changes to my Gerrit.

But here is the problem that I faced:
Let's say the change was in Open state on Client Gerrit when I initially copied it to my Gerrit using above command. On my Gerrit this change is in Open state.
After that the client submits that Change and now, I want to bring this new updated Change again.

If I do git fetch --all <client gerrit> and do a push again to my Gerrit it says "(Cannot create ref 'refs/changes/xxxxxxx' because it already exists.)" which is understandable. 

Is it not possible to just update refs/changes? 
Is there any workaround on this? 

Untested, but naively I would try:
`git push <my gerrit> +refs/changes/*:refs/changes/* -o notedb=allow

Daniele Sassoli

unread,
Jan 29, 2025, 3:48:01 AM1/29/25
to Repo and Gerrit Discussion
On Tuesday, 28 January 2025 at 15:14:40 UTC+1 Sven Selberg wrote:
On Tuesday, January 28, 2025 at 1:08:26 PM UTC+1 ishan badgainya wrote:
Hi Sven,
Thanks for the info!
I tried the following approach before I saw your reply.

git clone --mirror <client gerrit>
git push --mirror <my gerrit> -o notedb=allow
Gerrit stop , reindex, Gerrit start

I was able to push everything including the refs/changes to my Gerrit.

But here is the problem that I faced:
Let's say the change was in Open state on Client Gerrit when I initially copied it to my Gerrit using above command. On my Gerrit this change is in Open state.
After that the client submits that Change and now, I want to bring this new updated Change again.

Have you tried installing pull-replication on one of the nodes and adding your other Gerrit as remote?
So you don't have to keep doing this manually?

ishan badgainya

unread,
Jan 31, 2025, 8:31:04 AM1/31/25
to Repo and Gerrit Discussion
Hi Daniele,
I understand your point. 
But our use case is very specific. 
What we do is copy code from our client's Gerrit server to our Gerrit server. We can sync the code but cannot bring the Merge request entries.
We don't have access to our Client's Gerrit server to install the pull replication plugin.

We can only do Git based commands. 

Message has been deleted

Daniele Sassoli

unread,
Jan 31, 2025, 8:45:06 AM1/31/25
to Repo and Gerrit Discussion
Hi,

please use interleaved posting style[1] when using this mailing list.

[1] https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

On Friday, 31 January 2025 at 13:31:04 UTC ish...@kpit.com wrote:
Hi Daniele,
I understand your point. 
But our use case is very specific. 
What we do is copy code from our client's Gerrit server to our Gerrit server. We can sync the code but cannot bring the Merge request entries.
We don't have access to our Client's Gerrit server to install the pull replication plugin.

Yes, you would install pull-replication on your machine and it would fetch from your client's machine.
You can also filter which refs it should be fetching. 

Björn Pedersen

unread,
Feb 5, 2025, 3:12:44 AM2/5/25
to Repo and Gerrit Discussion
Daniele Sassoli schrieb am Freitag, 31. Januar 2025 um 14:45:06 UTC+1:
Hi,

please use interleaved posting style[1] when using this mailing list.

[1] https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

On Friday, 31 January 2025 at 13:31:04 UTC ish...@kpit.com wrote:
Hi Daniele,
I understand your point. 
But our use case is very specific. 
What we do is copy code from our client's Gerrit server to our Gerrit server. We can sync the code but cannot bring the Merge request entries.
We don't have access to our Client's Gerrit server to install the pull replication plugin.



What you want to achieve seems fragile at least. One gerrit installation needs to be the 'controlling' gerrit instance, unless you go 
the full multi-site (see gerrit docs and multisite plugin) path.
You could run your instance as a read-only(!) replica (that only is used for this remote gerrit instance) and use e.g. the pull-replication 
plugin to keep them somewhat in sync ( but you would need to listen to the remote events to trigger sync, of course).
Further problems that you should expect: user mapping, mis-matched server ids etc... 
Reply all
Reply to author
Forward
0 new messages