Fix deletion of draft comment refs
In NoteDb, we store draft comments in the All-Users repository. This improves performance in the googlesource.com deployment, as high-traffic repositories can be configured to bypass Gerrit ACL checks for the ref advertisement. This makes publishing comments non-atomic: after publishing comments successfully, the update of the draft branch may fail. For this reason, any NoteDb update that touches the draft ref in All-Users will schedule a deletion of all published comments for the change. If there were multiple patchsets, scheduling deletions of items that were not in the draft ref triggered a logic error in ChangeDraftUpdate, which caused the branch to become empty rather than deleted. This had the following consequences: * unused draft refs persisted in the All-Users repository, polluting the namespace. * published draft comments as well as deleted draft comments were kept in the history of the draft ref, keeping them alive for GC, and causing a steady increase of repository size. In other words, for this to trigger, a change would have to publish draft comments on a change with multiple patchsets, and a previously published comment. The problem was not visible to users of Gerrit. This changes fixes the problem by simply looking at the notemap to be serialized, and deleting the draft ref if the new notemap is empty. Existing refs must still be cleaned up. We could introduce code, perhaps in the ProjectConsistencyChecker, to remove the stale refs from All-Users. Change-Id: I6f7b65828bb047bbff041b4d78f6b40190e76219
This commit is contained in:
committed by
David Pursehouse
parent
5e80fdc639
commit
a47258be4e
@@ -198,10 +198,9 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
|
||||
return NO_OP_UPDATE;
|
||||
}
|
||||
|
||||
// If we touched every revision and there are no comments left, tell the
|
||||
// If there are no comments left, tell the
|
||||
// caller to delete the entire ref.
|
||||
boolean touchedAllRevs = updatedRevs.equals(rnm.revisionNotes.keySet());
|
||||
if (touchedAllRevs && !hasComments) {
|
||||
if (!rnm.noteMap.iterator().hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user