Migrating Gerrit DB from H2 to PostgreSQL

387 views
Skip to first unread message

David Culbertson

unread,
Jan 29, 2021, 5:46:48 PM1/29/21
to Repo and Gerrit Discussion
I've been tasked with migrating an H2 Gerrit database to PostgreSQL, and I have looked into multiple sets of online instructions. So far, I have yet to find one that works.  Every example is for 2.1.x the examples/scripts don't seem to work with my 3.3 instance of Gerrit.
 
Some examples of links found online that don't seem to work on my 3.3 server:
The problems I run into are:
  1. I can't get to the H2 database from the command-line (the "gsql" option doesn't exist for my instance of Gerri and the database is native, so I have no port/service to directly connect to the H2 DB/tables)
  2. When I open the database using an H2 tool on a system with GUI, most of the tables laid out in both examples don't exist
Anyone performed this migration or at least provide some guidance on where to look? Is there something I'm missing?  (I have the syntax to export the tables to CSV files and I can export these tables to CSV on another machine by copying the DB files over, but I can only find 5 or 6 of the 19-20 I see listed in every set of instructions I've been able to find and it's not inspiring a great deal of confidence.)

Any help is greatly appreciated!

Clark Boylan

unread,
Jan 29, 2021, 6:22:30 PM1/29/21
to David Culbertson, Repo and Gerrit Discussion
Gerrit 3.0 and newer store most of their data in git in what is called
"notedb". Essentially account, group, and change data go into
different git refs in various repos. The SQL database that remains is
the "accountPatchReviewDb" [0] so I'm going to assume this is what you
are trying to migrate from H2 to PostgreSQL. This database tracks
which files users have reviewed in a change. There is a migration tool
to migrate this DB from one backend to another [1].

The reason old documentation differs is that the content of the noteDB
was once stored in a SQL database as well. But that stopped being
possible with Gerrit 3.0.

I've never migrated an accountPatchReviewDb or used the migration tool
so am not much more help than pointing you at the docs. Note, [0] says
this migration must happen with the server offline. Others on this
list may have done this migration and have more information than me.
You may also want to double check that the H2 database you want to
migrate is the accountPatchReviewDb; I think H2 may also be used for
caches.

[0] https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#accountPatchReviewDb
[1] https://gerrit-review.googlesource.com/Documentation/pgm-MigrateAccountPatchReviewDb.html

David Culbertson

unread,
Jan 31, 2021, 6:48:35 PM1/31/21
to Repo and Gerrit Discussion
Thank you so much!  I'm going to make a second attempt at the process tonight, but at least now I know that I'm not entirely crazy.
Reply all
Reply to author
Forward
0 new messages