Migration of Gerrit Server Old to New

2,795 views
Skip to first unread message

Furosh One

unread,
Apr 9, 2010, 6:38:16 PM4/9/10
to Repo and Gerrit Discussion, Shawn Pearce
I was hoping to find out any steps either breif or steps for migration
of Old to New Gerrit Server.

I don't think I saw one on the documentation but maybe I just didn't
look right.

We're planning on using Pgsql and can dump and then restore but not
sure if any gotchas or any other steps that would help simplify our
needs.

I've just barely got my first Gerrit Install completed to test my
experience prior to going onto our production servers...

-Regards,
Gibran

Shawn Pearce

unread,
Apr 10, 2010, 2:40:44 PM4/10/10
to Furosh One, Repo and Gerrit Discussion
On Fri, Apr 9, 2010 at 15:38, Furosh One <fur...@gmail.com> wrote:
> I was hoping to find out any steps either breif or steps for migration
> of Old to New Gerrit Server.

Are you talking about *moving* the installation from one system to another?

Or are you talking about upgrading an existing installation to a newer
version of Gerrit Code Review?

Furosh One

unread,
Apr 12, 2010, 3:37:03 PM4/12/10
to Shawn Pearce, Repo and Gerrit Discussion
>
> Are you talking about *moving* the installation from one system to another?

Yes we have an existing Gerrit server running for some time, but many
factors which make it slow. Going to setup Gerrit on a new dedicated
server, but would like to get everything setup, then migrate it over
to the new server. Would probably need to completely backup the DB
(pgdump) then import into the new server.

The old server also has a /git/project_name/ <all git repos here>/
structure. And so we'd like to allow for this Gerrit or migration to
allow for having capability to have something like:
/git/project1/
/git/project2/
/git/project3/

Andy any other projects created under /git/.

Shawn Pearce

unread,
Apr 12, 2010, 5:01:41 PM4/12/10
to Furosh One, Repo and Gerrit Discussion
Furosh One <fur...@gmail.com> wrote:
> >
> > Are you talking about *moving* the installation from one system to another?
>
> Yes we have an existing Gerrit server running for some time, but many
> factors which make it slow. Going to setup Gerrit on a new dedicated
> server, but would like to get everything setup, then migrate it over
> to the new server. Would probably need to completely backup the DB
> (pgdump) then import into the new server.

OK. Yes, dump the database with pgdump and restore it on the
new server. I do this all of the time to help debug issues with
a production installation. Its basically just:

pg_dump -O -Fc reviewdb >dump
scp dump target:

createdb -E UTF-8 -O gerrit2 reviewdb
pg_restore -d reviewdb dump

Also make sure you completely copy over the Git repositories from the
source system to the destination. Its safest to do both the database
dump and the repository copy while the source server is shutdown.



> The old server also has a /git/project_name/ <all git repos here>/
> structure. And so we'd like to allow for this Gerrit or migration to
> allow for having capability to have something like:
> /git/project1/
> /git/project2/
> /git/project3/
>
> Andy any other projects created under /git/.

I think this is easy. Just edit your gerrit.config file on the
new server to point to /git/ instead of /git/project_name/.

But don't rename any existing Gerrit projects. To rename them you
have to do some surgery on the database records, as a lot of the
records are keyed by the project's name below that gerrit.basePath
variable in gerrit.config.

Furosh One

unread,
Apr 12, 2010, 6:10:43 PM4/12/10
to Shawn Pearce, Repo and Gerrit Discussion
Okay everything makes sense so far. Thanks.

Another question, which gots me confused...

>
>> The old server also has a /git/project_name/ <all git repos here>/
>> structure. And so we'd like to allow for this Gerrit or migration to
>> allow for having capability to have something like:
>> /git/project1/
>> /git/project2/
>> /git/project3/
>>
>> Andy any other projects created under /git/.
>
> I think this is easy.  Just edit your gerrit.config file on the
> new server to point to /git/ instead of /git/project_name/.
>
> But don't rename any existing Gerrit projects.  To rename them you
> have to do some surgery on the database records, as a lot of the
> records are keyed by the project's name below that gerrit.basePath
> variable in gerrit.config.
>

(sorry to change the name but think this may help clarify my question)

So as I mentioned our existing Gerrit server/setup like so:
/git/projectsA/*
/git/projectsB/*
/git/projectsC/* <-- Gerrit only using/displaying these.
/git/projectsD/*
* = lots of git repos.

I thought I would find /git/projectsC under gerrit.config but it's actually has:
[gerrit]
basepath = /git

How is it that Gerrit is only displaying and using the git repos
inside of /git/projectsC/ (based on its gerrit.config)?
Maybe you would know of another way this was accomplished or some
other file to check.

I'm assuming that only projects under C will be moved to the new
server since Gerrit has it on its page, but not sure what the DB will
have if gerrit.config has /git/.

Hope that was easy to follow.

Shawn Pearce

unread,
Apr 12, 2010, 6:17:28 PM4/12/10
to Furosh One, Repo and Gerrit Discussion
Furosh One <fur...@gmail.com> wrote:
> So as I mentioned our existing Gerrit server/setup like so:
> /git/projectsA/*
> /git/projectsB/*
> /git/projectsC/* <-- Gerrit only using/displaying these.
> /git/projectsD/*
> * = lots of git repos.
>
> I thought I would find /git/projectsC under gerrit.config but it's actually has:
> [gerrit]
> basepath = /git
>
> How is it that Gerrit is only displaying and using the git repos
> inside of /git/projectsC/ (based on its gerrit.config)?
> Maybe you would know of another way this was accomplished or some
> other file to check.

Check your server's projects table.

A repository called /git/projectsC/awesome/widgets.git will have
project name of 'projectsC/awesome/widgets' given that your basepath
is already '/git'.

My guess is that your projects table simply does not have records
for the projectsA/, projectsB/ and projectsD/ subdirectories, so
those are not displayed in the web UI.

Shawn Pearce

unread,
Apr 14, 2010, 2:16:40 PM4/14/10
to Furosh One, repo-discuss
Furosh One <fur...@gmail.com> wrote:
> >> How is it that Gerrit is only displaying and using the git repos
> >> inside of /git/projectsC/ (based on its gerrit.config)?
> >> Maybe you would know of another way this was accomplished or some
> >> other file to check.
> >
> > Check your server's projects table.
> >
> > A repository called /git/projectsC/awesome/widgets.git will have
> > project name of 'projectsC/awesome/widgets' given that your basepath
> > is already '/git'.
> >
> > My guess is that your projects table simply does not have records
> > for the projectsA/, projectsB/ and projectsD/ subdirectories, so
> > those are not displayed in the web UI.
>
> Okay I'll check the projects table in the DB. Do you see any issues
> occurring from this with the migration?

Probably not.

> Basically the developers don't want to see
> "projectsC/<all_git_repos_here> inside of Gerrit and would like for
> Gerrit to show "/git/*".

Huh. They want Gerrit to show /git/ in front of everything?
I'm fairly certain you can't do this, Gerrit won't accept "/"
in the first position of a project name. But you can do "git/".

> Since our gerrit basepath is /git inside of gerrit.config (old server)
> I'm suspecting dump and restore needs a bit of changing (perhaps not a
> biggie but will require the change)???

If you want "git/" in front of each project name, you need to set
gerrit.basePath to just "/".

You will also need to update all of the records to use that
new prefix. Completely untested, so try this on a backup of the
database, but its something like:

UPDATE projects SET name = 'git/' || SUBSTR(name, LENGTH('projectsC/'))
WHERE name <> (SELECT wild_project_name FROM system_config);

UPDATE ref_rights SET project_name = 'git/' || SUBSTR(project_name, LENGTH('projectsC/'))
WHERE project_name <> (SELECT wild_project_name FROM system_config);

UPDATE changes SET dest_project_name = 'git/' || SUBSTR(dest_project_name, LENGTH('projectsC/'));

UPDATE account_project_watches SET project_name = 'git/' || SUBSTR(project_name, LENGTH('projectsC/'));

I think that's it. Just the 4 tables need updating.

Furosh One

unread,
May 3, 2010, 1:24:37 PM5/3/10
to Shawn Pearce, Repo and Gerrit Discussion
On Wed, Apr 14, 2010 at 1:54 PM, Shawn Pearce <s...@google.com> wrote:
> Furosh One <fur...@gmail.com> wrote:
>
> As I said earlier in this thread:
>
> UPDATE projects SET name = SUBSTR(name, LENGTH('ssiafp/') + 1)
> WHERE name <> (SELECT wild_project_name FROM system_config);
>
> UPDATE ref_rights SET project_name = SUBSTR(project_name, LENGTH('ssiafp/') + 1)
> WHERE project_name <> (SELECT wild_project_name FROM system_config);
>
> UPDATE changes SET dest_project_name = SUBSTR(dest_project_name, LENGTH('ssiafp/') + 1);
>
> UPDATE account_project_watches SET project_name = SUBSTR(project_name, LENGTH('ssiafp/') + 1);
>
> Should let you drop the 'ssiafp/' prefix. Then just set your
> gerrit.basePath to the directory that holds the projects.
>

Hey Shawn,
Good news is I've been able to get Old server dump restored to New Server.

Updated all the schema versions from the schema-upgrades003_019.zip. I
got it up to 19.

So what I did next was this, I created an empty directory /gitrepos/
and then attempted to have the gerrit-2.1.2.3.war upgrade the schema
further. I placed in empty directory because prior, I added to
/android1/android/git/ and I had both OLD server's pre-fix (ssiaftp/)
and new pre-fix (git/).

This seems to be working as I expect:
============================

Upgrading database schema from version 19 to 20 ...
Upgrading database schema from version 20 to 21 ...
Upgrading database schema from version 21 to 22 ...
Upgrading database schema from version 22 to 23 ...
Upgrading database schema from version 23 to 24 ...
Upgrading database schema from version 24 to 25 ...
Upgrading database schema from version 25 to 26 ...
Upgrading database schema from version 26 to 27 ...
Upgrading database schema from version 27 to 28 ...
Upgrading database schema from version 28 to 29 ...
Upgrading database schema from version 29 to 30 ...
Execute the following SQL to drop unused objects:

DROP SEQUENCE project_id;
DROP TABLE project_rights;
ALTER TABLE accounts DROP COLUMN ssh_user_name;
ALTER TABLE account_external_ids DROP COLUMN last_used_on;
ALTER TABLE account_ssh_keys DROP COLUMN stored_on;
ALTER TABLE account_ssh_keys DROP COLUMN last_used_on;
ALTER TABLE projects DROP COLUMN project_id;

Execute now [Y/n]?Y

Initialized /home/gerrit2/review_site

Try to change existing /ssiafp pre-fix to something else.
The NEW path for this will be /android1/android/git/

[gerrit2@san-gerrit1 ~]$ psql -d reviewdb -U gerrit2
Welcome to psql 8.1.18, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

reviewdb=> UPDATE projects SET name = SUBSTR(name, LENGTH('ssiafp/') + 1)
reviewdb-> WHERE name <> (SELECT wild_project_name FROM system_config);
ERROR: duplicate key violates unique constraint "projects_pkey"

I'm not sure how to get around this. I was thinking about creating a
Plain-text backup and modifying the text file with search & replace
but not sure.

Have you seen this? Got any suggestions?

-FuRoSh...

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

Shawn Pearce

unread,
May 3, 2010, 2:37:42 PM5/3/10
to Furosh One, Repo and Gerrit Discussion
Furosh One <fur...@gmail.com> wrote:
> Try to change existing /ssiafp pre-fix to something else.
> The NEW path for this will be /android1/android/git/
>
> [gerrit2@san-gerrit1 ~]$ psql -d reviewdb -U gerrit2
> Welcome to psql 8.1.18, the PostgreSQL interactive terminal.
>
> Type: \copyright for distribution terms
> \h for help with SQL commands
> \? for help with psql commands
> \g or terminate with semicolon to execute query
> \q to quit
>
> reviewdb=> UPDATE projects SET name = SUBSTR(name, LENGTH('ssiafp/') + 1)
> reviewdb-> WHERE name <> (SELECT wild_project_name FROM system_config);
> ERROR: duplicate key violates unique constraint "projects_pkey"
>
> I'm not sure how to get around this. I was thinking about creating a
> Plain-text backup and modifying the text file with search & replace
> but not sure.

Sounds like there might be a project whose name doesn't start with
'ssiafp/' and which otherwise shares the name of one that does
after you chop off the first 7 characters?

I would try doing a `SELECT name FROM projects ORDER BY name` to
look at what projects you have, and see if you can figure out why
you are getting a duplicate when you drop the 'ssiafp/' prefix.

Or, maybe even look at:

SELECT SUBSTR(name, LENGTH('ssiafp/') + 1) AS new_name, name
FROM projects
ORDER BY new_name, name;

Furosh One

unread,
May 3, 2010, 3:06:55 PM5/3/10
to Shawn Pearce, Repo and Gerrit Discussion
You are correct, which was going to be my next question to ask about.
On OLD server where the dump came from, there are 5 directories under
/git/ and I'm attempting to only move the "/git/ssiafp/" one.

Old server:
$ ls /git/
Hiro Pyramid SandboxTom ssiafp TestProject

This means there will be some others project inside of the restored
database on the NEW server. Which now appear to be causing an issue. I
have only rsync'ed all the git repos in /git/ssiafp/ and shouldn't
need anything else.

I also noticed that there is Gerrit information like
{Hiro|Pyramid|SandboxTom|TestProject} Lead/Developers/Verifiers as
well as projects I should or need to remove.

Perhaps doing this prior to attempting to change "ssiafp/" pre-fix would help.

Any suggestions?

*I was considering deleting in a plain-text dump of current state but
not sure of any implications or issues this may create. Only cause I
really don't know how to correctly manipulate data within the pgsql
DB. Perhaps you can tell me of a much cleaner way to accomplish this.

-FuRoSh...

Furosh One

unread,
May 4, 2010, 1:33:51 AM5/4/10
to Shawn Pearce, Repo and Gerrit Discussion
Anyone else know enough about postgresql databases to know how to get
around this? Somewhat of a complex one-off incident, but I'm stuck...
:D

Shawn Pearce

unread,
May 4, 2010, 10:27:50 AM5/4/10
to Furosh One, Repo and Gerrit Discussion
On Mon, May 3, 2010 at 12:06, Furosh One <fur...@gmail.com> wrote:
> You are correct, which was going to be my next question to ask about.
> On OLD server where the dump came from, there are 5 directories under
> /git/ and I'm attempting to only move the "/git/ssiafp/" one.
>
> Old server:
> $ ls /git/
> Hiro  Pyramid  SandboxTom  ssiafp  TestProject
>
> This means there will be some others project inside of the restored
> database on the NEW server. Which now appear to be causing an issue. I
> have only rsync'ed all the git repos in /git/ssiafp/ and shouldn't
> need anything else.

Then try removing those projects not under ssiafp first:

DELETE FROM projects
WHERE name <> (SELECT wild_project_name FROM system_config)
AND name NOT LIKE 'ssiafp/%';


Then prune anything else related to those projects you just removed:

DELETE FROM account_project_watches WHERE
project_name NOT IN (SELECT name FROM projects);

DELETE FROM changes WHERE
dest_project_name NOT IN (SELECT name FROM projects);

DELETE FROM change_messages WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM patch_comments WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM patch_set_ancestors WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM patch_set_approvals WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM patch_sets WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM patches WHERE
change_id NOT IN (SELECT change_id FROM changes);

DELETE FROM starred_changes WHERE
change_id NOT IN (SELECT change_id FROM changes);


-- This table might have already been removed, that's OK.
--
DELETE FROM patch_set_info WHERE
change_id NOT IN (SELECT change_id FROM changes);


-- Depending on the schema version, this table may be
-- called "ref_rights" instead:
--
DELETE FROM project_rights WHERE
project_name NOT IN (SELECT name FROM projects);


> Perhaps doing this prior to attempting to change "ssiafp/" pre-fix would help.

Right, after doing that cleanup above, then you can try to remove the prefix.

Furosh One

unread,
May 4, 2010, 5:40:39 PM5/4/10
to Shawn Pearce, Repo and Gerrit Discussion
Thanks a whole bunch for this Shawn, definately wouldn't know what/how
to do what I need.
Ran first few without a problem, but got an Error one one below. (see comments)

> Then try removing those projects not under ssiafp first:
>
> DELETE FROM projects
> WHERE name <> (SELECT wild_project_name FROM system_config)
> AND name NOT LIKE 'ssiafp/%';
>
>
> Then prune anything else related to those projects you just removed:
>
> DELETE FROM account_project_watches WHERE
> project_name NOT IN (SELECT name FROM projects);
>
> DELETE FROM changes WHERE
> dest_project_name NOT IN (SELECT name FROM projects);
>
> DELETE FROM change_messages WHERE
> change_id NOT IN (SELECT change_id FROM changes);
>
> DELETE FROM patch_comments WHERE
> change_id NOT IN (SELECT change_id FROM changes);
>
> DELETE FROM patch_set_ancestors WHERE
> change_id NOT IN (SELECT change_id FROM changes);
>
> DELETE FROM patch_set_approvals WHERE
> change_id NOT IN (SELECT change_id FROM changes);
>
> DELETE FROM patch_sets WHERE
> change_id NOT IN (SELECT change_id FROM changes);

All these seem to working fine, without any issues.

> DELETE FROM patches WHERE
> change_id NOT IN (SELECT change_id FROM changes);

I get an error on this one:
reviewdb=> DELETE FROM patches WHERE
reviewdb-> change_id NOT IN (SELECT change_id FROM changes);
ERROR: relation "patches" does not exist

Perhaps this isn't much of an issue, since "patches" doesn't exist.
Should I just continue on or ?

Shawn Pearce

unread,
May 4, 2010, 5:42:24 PM5/4/10
to Furosh One, Repo and Gerrit Discussion
On Tue, May 4, 2010 at 14:40, Furosh One <fur...@gmail.com> wrote:
> Thanks a whole bunch for this Shawn, definately wouldn't know what/how
> to do what I need.
> Ran first few without a problem, but got an Error one one below. (see comments)
> I get an error on this one:
> reviewdb=> DELETE FROM patches WHERE
> reviewdb-> change_id NOT IN (SELECT change_id FROM changes);
> ERROR:  relation "patches" does not exist
>
> Perhaps this isn't much of an issue, since "patches" doesn't exist.
> Should I just continue on or ?

Yea, that's OK. We stopped caching that data in the database. It
cost more to write to the DB than it did to generate it on the fly.
Just ignore that statement. :-)

Furosh One

unread,
May 6, 2010, 5:02:40 PM5/6/10
to Shawn Pearce, Repo and Gerrit Discussion
Okay Shawn thanks for all the help so far! Really working great for me!!!

> UPDATE projects SET name = SUBSTR(name, LENGTH('ssiafp/') + 1)
> WHERE name <> (SELECT wild_project_name FROM system_config);
>
> UPDATE ref_rights SET project_name = SUBSTR(project_name, LENGTH('ssiafp/') + 1)
> WHERE project_name <> (SELECT wild_project_name FROM system_config);
>
> UPDATE changes SET dest_project_name = SUBSTR(dest_project_name, LENGTH('ssiafp/') + 1);
>
> UPDATE account_project_watches SET project_name = SUBSTR(project_name, LENGTH('ssiafp/') + 1);
>
> Should let you drop the 'ssiafp/' prefix. Then just set your
> gerrit.basePath to the directory that holds the projects.

So I've deleted all the non-ssiafp project out of the database, which
is what I needed to do prior to removing the ssiafp prefix steps
above. However, last time I did this it did what I wanted but somehow
didn't show up with the git/ prefix that I was looking for.

Whether that was correct or not, I don't know. The new gerrit
$basePath = /android1/android1/git/
I guess I was expecting to see this or at least the git/ part. So
maybe this was my issue.

Regardless I started over with the dump/restore, updated all
schema_version, init new review_site and script updated to
schema_version 30, then removed all non-ssiafp projects out of
database. So now...

Questions:
========
1). Rather than removing the ssiafp prefix, can you tell me how I can
go about replacing it with new_name?
Change ssiafp/ to git/?

2). Can you tell me how to remove all the other non-ssiafp
Leads/developers/verifiers out of the database?
Looking at the plain-text dump I see others I don't need-
Anonymous Users
Registered Users
Administrators
Hiro Leads
TestProject Leads
TestProject Developers
Hiro Developers
Hiro Verifiers
ssiafp Leads
ssiafp Verifiers
SandboxTom Leads
sprinkles Developers
ssiafp Developers

3). I understand first person to sign-in to new initialized gerrit
setup will be added as Administrator, do you think there will be any
issues related to this migration? Will the administrator also be
migrated, if so how can I be new Admin or added as admin?


I think that's all I need (unless I run into anymore issues) :D.

-FuRoSh...
*The Long-winded helpee*

Shawn Pearce

unread,
May 6, 2010, 10:29:18 PM5/6/10
to Furosh One, Repo and Gerrit Discussion
On Thu, May 6, 2010 at 14:02, Furosh One <fur...@gmail.com> wrote:
> Questions:
> ========
> 1). Rather than removing the ssiafp prefix, can you tell me how I can
> go about replacing it with new_name?
> Change ssiafp/ to git/?

UPDATE projects SET name = 'git/' || SUBSTR(name, LENGTH('ssiafp/') + 1)
WHERE name <> (SELECT wild_project_name FROM system_config);

|| in SQL is string concatenation. So that would remove 'ssiafp/'
prefix, and then add 'git/' before updating the name. Use the other
update statements from earlier in this thread to update the other
tables.

> 2). Can you tell me how to remove all the other non-ssiafp
> Leads/developers/verifiers out of the database?
> Looking at the plain-text dump I see others I don't need-
>  Anonymous Users
>  Registered Users
>  Administrators
>  Hiro Leads
>  TestProject Leads
>  TestProject Developers
>  Hiro Developers
>  Hiro Verifiers
>  ssiafp Leads
>  ssiafp Verifiers
>  SandboxTom Leads
>  sprinkles Developers
>  ssiafp Developers

You might be able to look at which groups aren't used in a permission:

SELECT g.name FROM account_groups g
WHERE NOT EXISTS (SELECT 1 FROM ref_rights r WHERE r.group_id = g.group_id)

then delete those groups, though don't remove Anonymous Users,
Registered Users or Administrators:

DELETE FROM account_groups WHERE name = '.....';

and purge the membership:

DELETE FROM account_group_members m
WHERE NOT EXISTS (SELECT 1 FROM account_groups g WHERE m.group_id =
g.group_id);

Removing the user accounts is a lot harder. You'd only want to remove
users which are never used anywhere in the database, and that's just
messy to do.

> 3). I understand first person to sign-in to new initialized gerrit
> setup will be added as Administrator, do you think there will be any
> issues related to this migration? Will the administrator also be
> migrated, if so how can I be new Admin or added as admin?

That won't happen here. Gerrit only does this if there are *no* users
in the accounts table at server startup. Since you are copying this
database from another server, and there is at least one user, this
won't occur.

To add yourself as an administrator, you'll need to either get another
admin to add you, or force your user account in by hand:

INSERT INTO account_group_members
(group_id, account_id)
VALUES
((SELECT admin_group_id FROM system_config),
YOUR_ACCOUNT_ID
);

Just get YOUR_ACCOUNT_ID from the Settings page. When you are done
with the insert, restart the server so it picks up your new group
membership.

Furosh One

unread,
May 19, 2010, 11:58:00 AM5/19/10
to Shawn Pearce, Repo and Gerrit Discussion
Anyone know of what this java error might indicate:

Then when I try to re-run 'java -jar gerrit-2.1.2.4.war init -d
review_site' for final time, keep getting java error:

Scanning /android1/android/git
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
String index out of range: -1
at java.lang.String.substring(String.java:1937)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:81)
at com.google.gerrit.server.git.GitProjectImporter.run(GitProjectImporter.java:59)
at com.google.gerrit.pgm.Init$SiteRun.importGit(Init.java:241)
at com.google.gerrit.pgm.Init.run(Init.java:86)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:155)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:89)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:47)
at Main.main(Main.java:25)

I can't tell what the error is complaining about enough to try to fix it.

$ ./review_site/bin/gerrit.sh start
Starting Gerrit Code Review: OK

I can start gerrit.sh script and web page loads but under Admin /
Projects nothing is listed.

Help (again) =/

-FuRoSh...
(almost there)

Ishaaq Chandy

unread,
May 19, 2010, 12:15:37 PM5/19/10
to Furosh One, Shawn Pearce, Repo and Gerrit Discussion
is there a git repo under a ".git" directory directly under
/android1/android/git ? If so, that would be why. You should probably
rename it to something like "foo.git" or some such...

furosh

unread,
May 20, 2010, 5:05:24 PM5/20/10
to Ishaaq Chandy, Shawn Pearce, Repo and Gerrit Discussion
On Wed, May 19, 2010 at 9:15 AM, Ishaaq Chandy <ish...@gmail.com> wrote:
> is there a git repo under a ".git" directory directly under
> /android1/android/git ? If so, that would be why. You should probably
> rename it to something like "foo.git" or some such...

Thanks, turns out I did have a .git under /android1/android/git/.git.

I mv to foo.git. I'm not sure how you knew this from looking at the
error messages, wish I knew but anyway, now I'm getting some new
errors:

Scanning /android1/android/git
Exception in thread "main"
com.google.gwtorm.client.OrmDuplicateKeyException: projects
at com.google.gwtorm.schema.sql.DialectPostgreSQL.convertError(DialectPostgreSQL.java:53)
at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:331)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:178)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:35)
at com.google.gwtorm.client.impl.AbstractAccess.insert(AbstractAccess.java:56)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:103)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:106)
at com.google.gerrit.server.git.GitProjectImporter.run(GitProjectImporter.java:59)
at com.google.gerrit.pgm.Init$SiteRun.importGit(Init.java:241)
at com.google.gerrit.pgm.Init.run(Init.java:86)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:155)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:89)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:47)
at Main.main(Main.java:25)
Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO
projects(description,use_contributor_agreements,use_signed_off_by,submit_type,name)VALUES(NULL,'N','N','M','.repo/manifests')
was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:293)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:171)
... 16 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key
violates unique constraint "projects_pkey"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
... 20 more

I'm not sure why I'm having so much trouble. I appreciate all the help
so far but I can't beleive this has been this complicated. I realize
this is a complex setup with what I've got, but this migration is very
complicated and I have managers/developers waiting for me to complete
this for over a month now =/

I think I'm almost there and hoping you guys can get across the
finish-line that seems so close, yet so far...

-FuRoSh...

Shawn Pearce

unread,
May 20, 2010, 5:15:07 PM5/20/10
to furosh, Repo and Gerrit Discussion
furosh <fur...@gmail.com> wrote:
> Exception in thread "main"
> com.google.gwtorm.client.OrmDuplicateKeyException: projects
...
> Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key
> violates unique constraint "projects_pkey"

Looks like your projects_id sequence got reset?

SELECT MAX(project_id) + 1 FROM projects;
ALTER SEQUENCE project_id RESTART WITH <result_from_above>;

This may have happened with account_id and account_group_id too,
so maybe also restart those?

SELECT MAX(account_id) + 1 FROM accounts;
ALTER SEQUENCE account_id RESTART WITH <result_from_above>;

SELECT MAX(account_group_id) + 1 FROM account_groups;
ALTER SEQUENCE account_group_id RESTART WITH <result_from_above>;

Furosh One

unread,
May 26, 2010, 3:51:22 PM5/26/10
to Shawn Pearce, Repo and Gerrit Discussion
On Thu, May 20, 2010 at 2:15 PM, Shawn Pearce <s...@google.com> wrote:
> furosh <fur...@gmail.com> wrote:
>> Exception in thread "main"
>> com.google.gwtorm.client.OrmDuplicateKeyException: projects
> ...
>> Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key
>> violates unique constraint "projects_pkey"
>
> Looks like your projects_id sequence got reset?
>
>  SELECT MAX(project_id) + 1 FROM projects;
>  ALTER SEQUENCE project_id RESTART WITH <result_from_above>;
>
> This may have happened with account_id and account_group_id too,
> so maybe also restart those?
>
>  SELECT MAX(account_id) + 1 FROM accounts;
>  ALTER SEQUENCE account_id RESTART WITH <result_from_above>;
>
>  SELECT MAX(account_group_id) + 1 FROM account_groups;
>  ALTER SEQUENCE account_group_id RESTART WITH <result_from_above>;
>

Was this done right cause here's my results:

RESULTS:
========
1).reviewdb=> SELECT MAX(project_id) + 1 FROM projects;
?column?
----------
733
(1 row)

reviewdb=> ALTER SEQUENCE project_id RESTART WITH 733;
ALTER SEQUENCE

2).reviewdb=> SELECT MAX(account_id) + 1 FROM accounts;
?column?
----------
1000104
(1 row)

reviewdb=> ALTER SEQUENCE account_id RESTART WITH 1000104;
ALTER SEQUENCE

3).reviewdb=> SELECT MAX(account_group_id) + 1 FROM account_groups;
ERROR: column "account_group_id" does not exist


Then re-tried the java -jar gerrit-2.1.2.4 -d review_site:
======================================
Scanning /android1/android/git


Exception in thread "main"
com.google.gwtorm.client.OrmDuplicateKeyException: projects

at com.google.gwtorm.schema.sql.DialectPostgreSQL.convertError(DialectPostgreSQL.java:53)
at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:331)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:178)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:35)
at com.google.gwtorm.client.impl.AbstractAccess.insert(AbstractAccess.java:56)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:103)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:106)
at com.google.gerrit.server.git.GitProjectImporter.run(GitProjectImporter.java:59)
at com.google.gerrit.pgm.Init$SiteRun.importGit(Init.java:241)
at com.google.gerrit.pgm.Init.run(Init.java:86)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:155)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:89)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:47)
at Main.main(Main.java:25)
Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO

projects(description,use_contributor_agreements,use_signed_off_by,submit_type,name)VALUES(NULL,'N','N','M','tools/repo')


was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:293)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:171)
... 16 more

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key

violates unique constraint "projects_project_id_key"


at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
... 20 more

-FuRoSh...
=/

Shawn Pearce

unread,
May 27, 2010, 5:18:51 PM5/27/10
to Furosh One, Repo and Gerrit Discussion
Furosh One <fur...@gmail.com> wrote:
> Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO
> projects(description,use_contributor_agreements,use_signed_off_by,submit_type,name)VALUES(NULL,'N','N','M','tools/repo')
> was aborted. Call getNextException to see the cause.
> at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
> at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:293)
> at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:171)
> ... 16 more
> Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key
> violates unique constraint "projects_project_id_key"
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
> ... 20 more

Oooh! This is a schema mismatch going on. You didn't drop all of
the objects you needed to. At a minimum you need to still do:

DROP SEQUENCE project_id;
ALTER TABLE projects DROP project_id;

Reply all
Reply to author
Forward
0 new messages