YvCeung commented on code in PR #7903:
URL: https://github.com/apache/incubator-seata/pull/7903#discussion_r2664059629


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -57,24 +59,35 @@ public class ClusterWatcherManager implements 
ClusterChangeListener {
 
     private static final Map<String, Long> GROUP_UPDATE_TERM = new 
ConcurrentHashMap<>();
 
+    private static final Map<Watcher<HttpContext>, Boolean> HTTP2_HEADERS_SENT 
= new ConcurrentHashMap<>();
+
     private final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor =
             new ScheduledThreadPoolExecutor(1, new 
NamedThreadFactory("long-polling", 1));
 
     @PostConstruct
     public void init() {
-        // Responds to monitors that time out
+        // Periodically check and respond to watchers that have timed out
         scheduledThreadPoolExecutor.scheduleAtFixedRate(
                 () -> {
                     for (String group : WATCHERS.keySet()) {
                         Optional.ofNullable(WATCHERS.remove(group))
                                 .ifPresent(watchers -> 
watchers.parallelStream().forEach(watcher -> {
-                                    if (System.currentTimeMillis() >= 
watcher.getTimeout()) {
-                                        watcher.setDone(true);
-                                        sendWatcherResponse(watcher, 
HttpResponseStatus.NOT_MODIFIED);
-                                    }
-                                    if (!watcher.isDone()) {
-                                        // Re-register
-                                        registryWatcher(watcher);
+                                    HttpContext context = 
watcher.getAsyncContext();
+                                    boolean isHttp2 = context instanceof 
HttpContext && context.isHttp2();
+                                    if (isHttp2) {
+                                        if 
(!context.getContext().channel().isActive()) {
+                                            watcher.setDone(true);
+                                            HTTP2_HEADERS_SENT.remove(watcher);
+                                        } else {
+                                            registryWatcher(watcher);

Review Comment:
   Yes, currently through integration testing, if a change event occurs and 
then another change event occurs within 500ms, the client will not receive the 
second notification because it has not re-registered. And it has been stable 
and reproducible. I will solve this problem.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to