Gerrit cannot be migrate from server to server and keep group permissions intact

479 views
Skip to first unread message

Repo man

unread,
Apr 10, 2012, 2:42:14 PM4/10/12
to repo-d...@googlegroups.com
Hi all,

This is a question for Shawn, but I guess anyone who has experience can comment on this as well.

I was trying to migrate the in-house Gerrit server from the old machine to the new one. The old machine and new machine has different hardware and IP addresses.

I shutdown Gerrit on old server and copy all "review_site" and "repositories" folders to the new machine. Edit the etc/gerrit.config file to use IP on the new machine.
Run "init -d" to re-initialize again, and call "review_site/bin/gerrit.sh start" to start Gerrit on the new server.

But after I go to the Gerrit web and login again using my OpenID (Using Google OpenID service), I find that all Groups are gone.
After I checked gsql, and I found that I'm now under a new Account ID, even though I'm using the same email address.

So Gerrit thinks I'm a new, different user, so it hides all the groups from me. 

So is this a known bug? Or Gerrit just cannot be migrate from server to server on different IP when using OpenID for authentication ? 

This is my Gerrit setup:
- Embedded H2 (think about migrate, but I don't think there's a tool to migrate away from embedded to MySQL)
- 2.1.7 Gerrit (Can't upgrade yet until I find a way to move from old server to new server without losing anything)

Thanks.
Sam.


Shawn Pearce

unread,
Apr 10, 2012, 2:49:51 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 11:42, Repo man <s.x...@sta.samsung.com> wrote:
> I was trying to migrate the in-house Gerrit server from the old machine to
> the new one. The old machine and new machine has different hardware and IP
> addresses.
>
> I shutdown Gerrit on old server and copy all "review_site" and
> "repositories" folders to the new machine. Edit the etc/gerrit.config file
> to use IP on the new machine.
> Run "init -d" to re-initialize again, and call "review_site/bin/gerrit.sh
> start" to start Gerrit on the new server.
>
> But after I go to the Gerrit web and login again using my OpenID (Using
> Google OpenID service), I find that all Groups are gone.
> After I checked gsql, and I found that I'm now under a new Account ID, even
> though I'm using the same email address.

This is caused by OpenID. Your OpenID provider ... the Google OpenID
service... gives out new unique OpenID strings for each host name you
visit. This is to prevent third parties from correlating your
movements across websites by combining their authentication logs
together. It also means you have to use the *EXACT SAME HOST NAME AND
PORT AND URL* of your Gerrit server when you move servers.

Repo man

unread,
Apr 10, 2012, 3:30:49 PM4/10/12
to repo-d...@googlegroups.com, Repo man
Thanks Shawn for your quick response.

So in your suggestion, what should I do in this case to migrate a new server without different hostname?

Thanks


On Tuesday, April 10, 2012 11:49:51 AM UTC-7, Shawn Pearce wrote:

Shawn Pearce

unread,
Apr 10, 2012, 3:33:52 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 12:30, Repo man <s.x...@sta.samsung.com> wrote:
> Thanks Shawn for your quick response.
>
> So in your suggestion, what should I do in this case to migrate a new server
> without different hostname?

Yes, keep the host name the same.

> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en

Repo man

unread,
Apr 10, 2012, 3:44:40 PM4/10/12
to repo-d...@googlegroups.com
After some investigation, it is not possible to keep it the same for now.
Any other way?

Thx


On Tuesday, April 10, 2012 12:33:52 PM UTC-7, Shawn Pearce wrote:

> To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

Shawn Pearce

unread,
Apr 10, 2012, 5:05:53 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 12:44, Repo man <s.x...@sta.samsung.com> wrote:
> After some investigation, it is not possible to keep it the same for now.
> Any other way?

Manually merge all of your new user accounts to your old user accounts
by editing the database records in accounts and account_external_ids.
Otherwise, no.

>> > To unsubscribe, email repo-discuss...@googlegroups.com

> --
> To unsubscribe, email repo-discuss...@googlegroups.com

Repo man

unread,
Apr 10, 2012, 5:09:58 PM4/10/12
to repo-d...@googlegroups.com, Repo man
Hi Shawn,

I actually tried that by copying (replace) the HTTP OpenID URL from new account to the old account, keeping the old account's Account_ID the same, but it won't let me login, but instead asking me "contact admin" at the login page.
What's the proper way to merge it?


Thx

On Tuesday, April 10, 2012 2:05:53 PM UTC-7, Shawn Pearce wrote:

>> > To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

> To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

Shawn Pearce

unread,
Apr 10, 2012, 5:13:13 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 14:09, Repo man <s.x...@sta.samsung.com> wrote:
> I actually tried that by copying (replace) the HTTP OpenID URL from new
> account to the old account, keeping the old account's Account_ID the same,
> but it won't let me login, but instead asking me "contact admin" at the
> login page.

Was there an error message in the error log? I think there may have
been some confusion in the database records here so it gave up and
refused to login in the user.

> What's the proper way to merge it?

Typically its delete the old account_external_id record and then
update the new one to use the old account_id.

>> >> > To unsubscribe, email repo-discuss...@googlegroups.com

>> > To unsubscribe, email repo-discuss...@googlegroups.com

> To unsubscribe, email repo-discuss...@googlegroups.com

Repo man

unread,
Apr 10, 2012, 7:25:55 PM4/10/12
to repo-d...@googlegroups.com, Repo man

Hi Shawn,

It actually work now by delete the old account_external_id record and then

update the new one to use the old account_id.

No error!

But is that mean I have to do that for all users one-by-one or wrote a SQL script for it?


My another question is:

Is there any advantage migrating just the database from embedded H2 to a JDBC H2?


I was thinking about migrating from embedded H2 to MySQL as I know you guys were planning this for future release of Gerrit, but I don't think Gerrit now has a tool for that because I always end up in scheme error when loading the backup.sql onto MySQL.

Thx.


On Tuesday, April 10, 2012 2:13:13 PM UTC-7, Shawn Pearce wrote:

>> >> > To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

>> > To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

> To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

Shawn Pearce

unread,
Apr 10, 2012, 7:41:00 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 16:25, Repo man <s.x...@sta.samsung.com> wrote:
> It actually work now by delete the old account_external_id record and then
>
> update the new one to use the old account_id.
>
> No error!
>
> But is that mean I have to do that for all users one-by-one or wrote a SQL
> script for it?

Yes.

> Is there any advantage migrating just the database from embedded H2 to a
> JDBC H2?

Doesn't make much a difference here, either way its H2. I guess if you
use the JDBC H2 you can use a cluster form, or run H2 as its own
process. But not sure that is a huge win.

> I was thinking about migrating from embedded H2 to MySQL as I know you guys
> were planning this for future release of Gerrit, but I don't think Gerrit
> now has a tool for that because I always end up in scheme error when loading
> the backup.sql onto MySQL.

Right, we don't have tools and thus don't support converting H2 to
MySQL. You might be able to find something on the web that you can
modify to do this for you. The schema as far as table layout goes is
the same, its just that the two dialects of SQL aren't really
compatible.

Repo man

unread,
Apr 10, 2012, 7:46:36 PM4/10/12
to repo-d...@googlegroups.com

Will you guys planning to write a tool to convert that?
Or moving away from H2 embedded in the future? which will migrate from H2 embedded to MySQL?



On Tuesday, April 10, 2012 4:41:00 PM UTC-7, Shawn Pearce wrote:

Shawn Pearce

unread,
Apr 10, 2012, 7:53:22 PM4/10/12
to Repo man, repo-d...@googlegroups.com
On Tue, Apr 10, 2012 at 16:46, Repo man <s.x...@sta.samsung.com> wrote:
>
> Will you guys planning to write a tool to convert that?

No.

> Or moving away from H2 embedded in the future?

We will be making changes in the future to move data from SQL storage
to Git based storage, so yes we will migrate some data out of H2.

> which will migrate from H2
> embedded to MySQL?

No, we aren't going to write tools to convert from H2 to MySQL. Nor
are we going to even attempt the crazy idea of embedding MySQL into
the Gerrit server. Some things just shouldn't mix. Embedding MySQL
daemon into a Java process is probably one of those combinations that
should never be attempted by a sane person. Or a crazy person.

Jason Axelson

unread,
Apr 10, 2012, 5:12:56 PM4/10/12
to Repo man, repo-d...@googlegroups.com
Hi,

I've successfully moved my Gerrit server to a new hostname while using
OpenId. Here are the basic steps:

* Shutdown existing gerrit instance
* Copy entire site path to new server
* Start gerrit on the new server (I didn't re-run init and I don't
think it's necessary)
* Log in with OpenId to new server
** Gerrit will create a new account for you, this is expected, but
don't fill out any info on the new profile
* Log in to gsql (ssh <username>@<gerrit-hostname> -p <gerrit-port> gerrit gsql)
** Run select * from account_external_ids where
email_address="<users-email-address>"
*** Note the correct account id of the account (should be the lower account_id)
** Run something like "update account_external_ids set
account_id=<account_id_from_prev_step> where
email_address="<users-email-address>"
** Delete the new account from account table: delete from account
where account_id=<new-account-d>

Of course you have to do this for every user and it is also a bad user
experience when they first log in and you can't do this for them
without their password.

Jason

>> > To unsubscribe, email repo-discuss...@googlegroups.com

> --
> To unsubscribe, email repo-discuss...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages