diff options
author | David Ostrovsky <david@ostrovsky.org> | 2020-05-02 07:51:46 +0200 |
---|---|---|
committer | David Ostrovsky <david.ostrovsky@gmail.com> | 2020-05-04 07:37:33 +0000 |
commit | a4d8402ad9cfb3ce842891cf34dcbe9eeac6213f (patch) | |
tree | e0ca32887f370b0e53eeb69120d2efe15a15f9f6 | |
parent | 6e43beda49efaa17832c618546d2147cb3f41ca8 (diff) |
Schema_146: Periodically run full gc
On very big sites (300,000 accounts) it is not sufficient to only run
pack refs. Full gc should be run every 100k accounts and at the end
of the migration to leave the All-Users repository in a good shape.
Change-Id: Ic0bcce93f557b93c24185df3fbd84d036269669d
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_146.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_146.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_146.java index 64e9123c95..a189d592c9 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_146.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_146.java @@ -99,7 +99,9 @@ public class Schema_146 extends SchemaVersion { protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException { ui.message("Migrating accounts"); Set<Entry<Account.Id, Timestamp>> accounts = scanAccounts(db, ui).entrySet(); + ui.message("Run full gc as preparation for the migration"); gc(ui); + ui.message(String.format("... (%.3f s) full gc completed", elapsed())); Set<List<Entry<Account.Id, Timestamp>>> batches = Sets.newHashSet(Iterables.partition(accounts, 500)); ExecutorService pool = createExecutor(ui); @@ -112,6 +114,9 @@ public class Schema_146 extends SchemaVersion { } ui.message( String.format("... (%.3f s) Migrated all %d accounts to schema 146", elapsed(), i.get())); + ui.message("Run full gc"); + gc(ui); + ui.message(String.format("... (%.3f s) full gc completed", elapsed())); } private ExecutorService createExecutor(UpdateUI ui) { @@ -142,7 +147,14 @@ public class Schema_146 extends SchemaVersion { int count = i.incrementAndGet(); showProgress(ui, count); if (count % 1000 == 0) { - gc(repo, true, ui); + boolean runFullGc = count % 100000 == 0; + if (runFullGc) { + ui.message("Run full gc"); + } + gc(repo, !runFullGc, ui); + if (runFullGc) { + ui.message(String.format("... (%.3f s) full gc completed", elapsed())); + } } } } catch (IOException e) { |