Merge branch 'stable-3.2'
* stable-3.2: Increase draft zombie cleanup CHUNK_SIZE to 3000 refs Remove outdated reference to GWT from access control documentation Update delete-project plugin to latest master revision Display zombie removal progress during upgrade Change-Id: I616b6303cdab21ceb10909d54135372ac150736c
This commit is contained in:
@@ -1425,8 +1425,7 @@ When applying a query limit to a user the largest value granted by
|
||||
any of their groups is used.
|
||||
|
||||
This limit applies not only to the link:cmd-query.html[`gerrit query`]
|
||||
command, but also to the web UI results pagination size in the new
|
||||
PolyGerrit UI and, limited to the full project list, in the old GWT UI.
|
||||
command, but also to the web UI results pagination size.
|
||||
|
||||
|
||||
[[capability_readAs]]
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
@@ -47,12 +48,16 @@ public class DeleteZombieCommentsRefs {
|
||||
|
||||
private static final String EMPTY_TREE_ID = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
||||
private static final String DRAFT_REFS_PREFIX = "refs/draft-comments";
|
||||
private static final int CHUNK_SIZE = 100; // log progress after deleting every CHUNK_SIZE refs
|
||||
|
||||
// Number of refs deleted at once in a batch ref-update.
|
||||
// Log progress after deleting every CHUNK_SIZE refs
|
||||
private static final int CHUNK_SIZE = 3000;
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final AllUsersName allUsers;
|
||||
private final int cleanupPercentage;
|
||||
private Repository allUsersRepo;
|
||||
private final Consumer<String> uiConsumer;
|
||||
|
||||
public interface Factory {
|
||||
DeleteZombieCommentsRefs create(int cleanupPercentage);
|
||||
@@ -63,9 +68,18 @@ public class DeleteZombieCommentsRefs {
|
||||
AllUsersName allUsers,
|
||||
GitRepositoryManager repoManager,
|
||||
@Assisted Integer cleanupPercentage) {
|
||||
this(allUsers, repoManager, cleanupPercentage, (msg) -> {});
|
||||
}
|
||||
|
||||
public DeleteZombieCommentsRefs(
|
||||
AllUsersName allUsers,
|
||||
GitRepositoryManager repoManager,
|
||||
Integer cleanupPercentage,
|
||||
Consumer<String> uiConsumer) {
|
||||
this.allUsers = allUsers;
|
||||
this.repoManager = repoManager;
|
||||
this.cleanupPercentage = (cleanupPercentage == null) ? 100 : cleanupPercentage;
|
||||
this.uiConsumer = uiConsumer;
|
||||
}
|
||||
|
||||
public void execute() throws IOException {
|
||||
@@ -74,15 +88,17 @@ public class DeleteZombieCommentsRefs {
|
||||
List<Ref> draftRefs = allUsersRepo.getRefDatabase().getRefsByPrefix(DRAFT_REFS_PREFIX);
|
||||
List<Ref> zombieRefs = filterZombieRefs(draftRefs);
|
||||
|
||||
logger.atInfo().log(
|
||||
"Found a total of %d zombie draft refs in %s repo.", zombieRefs.size(), allUsers.get());
|
||||
logInfo(
|
||||
String.format(
|
||||
"Found a total of %d zombie draft refs in %s repo.",
|
||||
zombieRefs.size(), allUsers.get()));
|
||||
|
||||
logger.atInfo().log("Cleanup percentage = %d", cleanupPercentage);
|
||||
logInfo(String.format("Cleanup percentage = %d", cleanupPercentage));
|
||||
zombieRefs =
|
||||
zombieRefs.stream()
|
||||
.filter(ref -> Change.Id.fromAllUsersRef(ref.getName()).get() % 100 < cleanupPercentage)
|
||||
.collect(toImmutableList());
|
||||
logger.atInfo().log("Number of zombie refs to be cleaned = %d", zombieRefs.size());
|
||||
logInfo(String.format("Number of zombie refs to be cleaned = %d", zombieRefs.size()));
|
||||
|
||||
long zombieRefsCnt = zombieRefs.size();
|
||||
long deletedRefsCnt = 0;
|
||||
@@ -124,8 +140,15 @@ public class DeleteZombieCommentsRefs {
|
||||
return allUsersRepo.parseCommit(ref.getObjectId()).getTree().getName().equals(EMPTY_TREE_ID);
|
||||
}
|
||||
|
||||
private void logInfo(String message) {
|
||||
logger.atInfo().log(message);
|
||||
uiConsumer.accept(message);
|
||||
}
|
||||
|
||||
private void logProgress(long deletedRefsCount, long allRefsCount, long elapsed) {
|
||||
logger.atInfo().log(
|
||||
"Deleted %d/%d zombie draft refs (%d seconds)\n", deletedRefsCount, allRefsCount, elapsed);
|
||||
logInfo(
|
||||
String.format(
|
||||
"Deleted %d/%d zombie draft refs (%d seconds)",
|
||||
deletedRefsCount, allRefsCount, elapsed));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public class Schema_182 implements NoteDbSchemaVersion {
|
||||
public void upgrade(Arguments args, UpdateUI ui) throws Exception {
|
||||
AllUsersName allUsers = args.allUsers;
|
||||
GitRepositoryManager gitRepoManager = args.repoManager;
|
||||
DeleteZombieCommentsRefs cleanup = new DeleteZombieCommentsRefs(allUsers, gitRepoManager, 100);
|
||||
DeleteZombieCommentsRefs cleanup =
|
||||
new DeleteZombieCommentsRefs(allUsers, gitRepoManager, 100, ui::message);
|
||||
cleanup.execute();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user