RefReplicatedEvent for a change deletion?

51 views
Skip to first unread message

Makson Lee

unread,
May 16, 2017, 1:39:33 AM5/16/17
to Repo and Gerrit Discussion
a change is deleted, then it is replicated to slave, then a RefReplicatedEvent is posted, right?

but, when you post an event, the server will check the visibility of the reference you post to, then how do you check it against a deleted change?

169   protected boolean isVisibleTo(Event event, CurrentUser user) throws OrmException {
170     if (event instanceof RefEvent) {
171       RefEvent refEvent = (RefEvent) event;
172       String ref = refEvent.getRefName();
173       if (PatchSet.isChangeRef(ref)) {
174         Change.Id cid = PatchSet.Id.fromRef(ref).getParentKey();
175         Change change =
176             notesFactory.create(dbProvider.get(), refEvent.getProjectNameKey(), cid).getChange();
177         return isVisibleTo(change, user);
178       }
179       return isVisibleTo(refEvent.getBranchNameKey(), user);
180     } else if (event instanceof ProjectEvent) {
181       return isVisibleTo(((ProjectEvent) event).getProjectNameKey(), user);
182     }
183     return true;
184   }


Makson Lee

unread,
May 16, 2017, 5:28:59 PM5/16/17
to Repo and Gerrit Discussion
more details, as mentioned in [1], delete changes is a new feature in 2.14, which could introduce the following error in master-slaves environment,

[2017-05-17 05:26:27,227] [ReplicateTo-nj-git-test-2] ERROR com.googlesource.gerrit.plugins.replication.PushResultProcessing$GitUpdateProcessing : Cannot post event
com.google.gerrit.server.project.NoSuchChangeException: 934
        at com.google.gerrit.server.notedb.ChangeNotes.onLoad(ChangeNotes.java:574)
        at com.google.gerrit.server.notedb.AbstractChangeNotes.load(AbstractChangeNotes.java:161)
        at com.google.gerrit.server.notedb.ChangeNotes$Factory.create(ChangeNotes.java:183)
        at com.google.gerrit.common.EventBroker.isVisibleTo(EventBroker.java:176)
        at com.google.gerrit.common.EventBroker.fireEvent(EventBroker.java:132)
        at com.google.gerrit.common.EventBroker.postEvent(EventBroker.java:94)
        at com.googlesource.gerrit.plugins.replication.PushResultProcessing$GitUpdateProcessing.postEvent(PushResultProcessing.java:189)
        at com.googlesource.gerrit.plugins.replication.PushResultProcessing$GitUpdateProcessing.onRefReplicatedToAllNodes(PushResultProcessing.java:181)
        at com.googlesource.gerrit.plugins.replication.ReplicationState.doRefPushTasksCompleted(ReplicationState.java:136)
        at com.googlesource.gerrit.plugins.replication.ReplicationState.notifyRefReplicated(ReplicationState.java:98)
        at com.googlesource.gerrit.plugins.replication.PushOne.updateStates(PushOne.java:671)
        at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:434)
        at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:323)
        at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:83)
        at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:288)
        at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:285)
        at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:217)
        at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:193)
        at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
        at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:292)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:418)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)

Hugo Arès

unread,
May 18, 2017, 1:16:55 PM5/18/17
to Repo and Gerrit Discussion
As you using notedb? I tried reproducing this issue but I get NullPointerException instead of NoSuchChangeException:

java.lang.NullPointerException: change 262 not found in ReviewDb
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
    at com.google.gerrit.server.notedb.ChangeNotes$Factory.loadChangeFromDb(ChangeNotes.java:166)
    at com.google.gerrit.server.notedb.ChangeNotes$Factory.create(ChangeNotes.java:182)
    at com.google.gerrit.common.EventBroker.isVisibleTo(EventBroker.java:183)
    at com.google.gerrit.common.EventBroker.fireEvent(EventBroker.java:138)
    at com.google.gerrit.common.EventBroker.postEvent(EventBroker.java:100)
    at com.googlesource.gerrit.plugins.replication.PushResultProcessing$GitUpdateProcessing.postEvent(PushResultProcessing.java:189)
    at com.googlesource.gerrit.plugins.replication.PushResultProcessing$GitUpdateProcessing.onRefReplicatedToOneNode(PushResultProcessing.java:176)
    at com.googlesource.gerrit.plugins.replication.ReplicationState.notifyRefReplicated(ReplicationState.java:77)

    at com.googlesource.gerrit.plugins.replication.PushOne.updateStates(PushOne.java:671)
    at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:434)
    at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:323)
    at com.googlesource.gerrit.plugins.replication.PushOne.access$0(PushOne.java:301)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:288)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:1)

    at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:217)
    at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:193)
    at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
    at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:292)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:418)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Hugo Arès

unread,
May 18, 2017, 1:29:07 PM5/18/17
to Repo and Gerrit Discussion

Hugo Arès

unread,
May 18, 2017, 1:55:28 PM5/18/17
to Repo and Gerrit Discussion
https://gerrit-review.googlesource.com/#/c/107256/ should definitely fix your issue, last patchset also fix issue when notedb is not enabled.

Makson Lee

unread,
May 18, 2017, 7:04:15 PM5/18/17
to Repo and Gerrit Discussion
yep, it does fix the issue, thanks.
Reply all
Reply to author
Forward
0 new messages