Skip to content

Commit e476593

Browse files
committed
address review
1 parent a782e55 commit e476593

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

pinot-server/src/main/java/org/apache/pinot/server/starter/helix/ServerGrpcChannelBackoffResetHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public ServerGrpcChannelBackoffResetHandler(HelixAdmin helixAdmin, String cluste
7777
@Override
7878
public synchronized void onInstanceConfigChange(List<InstanceConfig> instanceConfigs,
7979
NotificationContext context) {
80+
// Only process INIT (listener registration) and CALLBACK (ZK data/child change).
81+
// Ignore FINALIZE (listener unregistration) and other types.
82+
8083
// INIT: first callback when the listener is registered (full cluster snapshot).
8184
// isChildChange: an instance ZK node was added or removed under /CONFIGS/PARTICIPANT.
8285
// Both require a full scan to rebuild _shuttingDownServers from the current cluster state.
@@ -87,10 +90,6 @@ public synchronized void onInstanceConfigChange(List<InstanceConfig> instanceCon
8790
// An existing instance's config changed (e.g. IS_SHUTDOWN_IN_PROGRESS toggled).
8891
// pathChanged is the ZK path of the specific instance that changed.
8992
String pathChanged = context.getPathChanged();
90-
if (pathChanged == null) {
91-
// Shouldn't happen, but be defensive.
92-
return;
93-
}
9493
String instanceName = pathChanged.substring(pathChanged.lastIndexOf('/') + 1);
9594
handleSingleInstanceChange(instanceName);
9695
}

pinot-server/src/test/java/org/apache/pinot/server/starter/helix/ServerGrpcChannelBackoffResetHandlerTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,17 @@ private NotificationContext createCallbackContextForInstance(String instanceId)
230230
}
231231

232232
@Test
233-
public void testNullPathChangedIsNoOp() {
234-
// Simulate a CALLBACK notification where pathChanged is null (defensive null-check).
235-
// A null pathChanged is unexpected, so the handler should silently return without
236-
// any interactions rather than NPE on pathChanged.substring().
237-
_handler.onInstanceConfigChange(Collections.emptyList(), createCallbackContextWithNullPath());
233+
public void testFinalizeNotificationIsNoOp() {
234+
// Simulate a FINALIZE notification where pathChanged is null. The listener should ignore this.
235+
_handler.onInstanceConfigChange(Collections.emptyList(), createFinalizeContextWithNullPath());
238236

239237
verify(_mailboxService, never()).resetConnectBackoff(any(), anyInt());
240238
verify(_helixAdmin, never()).getInstancesInCluster(any());
241239
}
242240

243-
private NotificationContext createCallbackContextWithNullPath() {
241+
private NotificationContext createFinalizeContextWithNullPath() {
244242
NotificationContext context = new NotificationContext(_helixManager);
245-
context.setType(NotificationContext.Type.CALLBACK);
243+
context.setType(NotificationContext.Type.FINALIZE);
246244
// pathChanged is not set, so getPathChanged() returns null
247245
return context;
248246
}

0 commit comments

Comments
 (0)