Package com.google.gerrit.server.notedb
Class DeleteZombieCommentsRefs
- java.lang.Object
-
- com.google.gerrit.server.notedb.DeleteZombieCommentsRefs
-
public class DeleteZombieCommentsRefs extends Object
This class can be used to clean zombie draft comments refs. More context in https://gerrit-review.googlesource.com/c/gerrit/+/246233The implementation has two cases for detecting zombie drafts:
- An earlier bug in the deletion of draft comments
refs/draft-comments/$change_id_short/$change_id/$user_id
caused some draft refs to remain in Git and not get deleted. These refs point to an empty tree. We delete such refs. - Inspecting all draft-comment refs. Check for each draft if there exists a published comment
with the same UUID. These comments are called zombie drafts. If the program is run in
dryRun
mode, the zombie draft IDs will only be logged for tracking, otherwise they will also be deleted.
- An earlier bug in the deletion of draft comments
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DeleteZombieCommentsRefs.Factory
-
Constructor Summary
Constructors Constructor Description DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, ChangeNotes.Factory changeNotesFactory, DraftCommentNotes.Factory draftNotesFactory, CommentsUtil commentsUtil, ChangeUpdate.Factory changeUpdateFactory, IdentifiedUser.GenericFactory userFactory, Integer cleanupPercentage)
DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, ChangeNotes.Factory changeNotesFactory, DraftCommentNotes.Factory draftNotesFactory, CommentsUtil commentsUtil, ChangeUpdate.Factory changeUpdateFactory, IdentifiedUser.GenericFactory userFactory, Integer cleanupPercentage, boolean dryRun)
DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, Integer cleanupPercentage, Consumer<String> uiConsumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
deleteDraftCommentsThatAreAlsoPublished()
Iterates over all draft refs in All-Users repository.void
execute()
-
-
-
Constructor Detail
-
DeleteZombieCommentsRefs
public DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, ChangeNotes.Factory changeNotesFactory, DraftCommentNotes.Factory draftNotesFactory, CommentsUtil commentsUtil, ChangeUpdate.Factory changeUpdateFactory, IdentifiedUser.GenericFactory userFactory, Integer cleanupPercentage)
-
DeleteZombieCommentsRefs
public DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, ChangeNotes.Factory changeNotesFactory, DraftCommentNotes.Factory draftNotesFactory, CommentsUtil commentsUtil, ChangeUpdate.Factory changeUpdateFactory, IdentifiedUser.GenericFactory userFactory, Integer cleanupPercentage, boolean dryRun)
-
DeleteZombieCommentsRefs
public DeleteZombieCommentsRefs(AllUsersName allUsers, GitRepositoryManager repoManager, Integer cleanupPercentage, Consumer<String> uiConsumer)
-
-
Method Detail
-
execute
public void execute() throws IOException
- Throws:
IOException
-
deleteDraftCommentsThatAreAlsoPublished
public int deleteDraftCommentsThatAreAlsoPublished() throws IOException
Iterates over all draft refs in All-Users repository. For each draft ref, checks if there exists a published comment with the same UUID and deletes the draft ref if that's the case because it is a zombie draft.- Returns:
- the number of detected and deleted zombie draft comments.
- Throws:
IOException
-
-