-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NotificationControllerV2#handleMessage may set outdated result #5059
Comments
🤖 Hey there, @PleaseGiveMeTheCoke! 👋 I'm Dosu, a friendly bot here to assist you with bugs, answer your queries, and guide you on your journey to become a contributor while we wait for a human maintainer. Let's dive into this together! 🏊 Yes, it is possible that the private Map<String, ApolloConfigNotification> filterNotifications(String appId,
List<ApolloConfigNotification> notifications) {
Map<String, ApolloConfigNotification> filteredNotifications = Maps.newHashMap();
for (ApolloConfigNotification notification : notifications) {
if (Strings.isNullOrEmpty(notification.getNamespaceName())) {
continue;
}
//strip out .properties suffix
String originalNamespace = namespaceUtil.filterNamespaceName(notification.getNamespaceName());
notification.setNamespaceName(originalNamespace);
//fix the character case issue, such as FX.apollo <-> fx.apollo
String normalizedNamespace = namespaceUtil.normalizeNamespace(appId, originalNamespace);
// in case client side namespace name has character case issue and has difference notification ids
// such as FX.apollo = 1 but fx.apollo = 2, we should let FX.apollo have the chance to update its notification id
// which means we should record FX.apollo = 1 here and ignore fx.apollo = 2
if (filteredNotifications.containsKey(normalizedNamespace) &&
filteredNotifications.get(normalizedNamespace).getNotificationId() < notification.getNotificationId()) {
continue;
}
filteredNotifications.put(normalizedNamespace, notification);
}
return filteredNotifications;
} You can find this code in the NotificationControllerV2.java file. The I hope this answers your question. If you need further clarification, feel free to ask. Best regards, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Dosu所说的这个关于NotificationId的比较似乎和我说的场景不一样。
This comparison Dosu's talking about regarding NotificationId doesn't seem to be the same scenario I'm talking about.
|
🤖 The Apollo configuration management system ensures that the NotificationId set in the Here is the relevant code snippet: ReleaseMessage latest = releaseMessageService.findLatestReleaseMessageForMessages(watchedKeys);
if (latest != null && latest.getId() != notificationId) {
deferredResult.setResult(new ResponseEntity<>(
new ApolloConfigNotification(namespace, latest.getId()), HttpStatus.OK));
} If the Here is the relevant code snippet: if (!deferredResults.containsKey(content)) {
return;
}
List<DeferredResult<ResponseEntity<ApolloConfigNotification>>> results =
Lists.newArrayList(deferredResults.get(content));
for (DeferredResult<ResponseEntity<ApolloConfigNotification>> result : results) {
result.setResult(notification);
} So, the The In the context of Apollo, a You can find more details in the source code of Apollo:
I hope this helps! If you have any more questions, feel free to ask. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
I don't think we need to make sure the NotificationId set in the handleMessage method must be greater than the client side. The notification is only an event telling the client that some new configuration released. Even though the id is smaller than the client side, that only means the client already fetched the latest configurations. And we had the notification id check logic in ConfigController. |
Thanks for responding to my query, I have found the checksum logic for the notificationId in the ConfigController as you said, which does ensure that the client gets the latest configuration every time it fetches it. |
It could be done. However, I suspect the chances that the server-side notification ID is less than the client-side is very rare, so it's not that necessary. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions. |
At the end of the NotificationControllerV2#handleMessage method, the result of the deferredResults are set in the following way
Is it possible that the notificationId in configNotification is less than the id on the client side, causing this to be an unnecessary result notification?
The text was updated successfully, but these errors were encountered: