hello-stephen commented on code in PR #71174:
URL: https://github.com/apache/doris/pull/71174#discussion_r4749982144


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java:
##########
@@ -246,16 +247,26 @@ private <T> T masterCallWithRetry(ThriftCall<T> call, 
String errorMsg, int timeo
         throw new RuntimeException(errorMsg + ":" + lastMessage, 
lastException);
     }
 
+    public int getClusterId() {
+        if (clusterId == null) {

Review Comment:
   [P2] Refresh a legacy remote cluster ID after upgrade
   
   If this FE accesses an older native remote Doris cluster, `listBackends()` 
stores the omitted `cluster_id` as `0`, and this getter never refreshes it. 
After the remote FEs/BEs upgrade with the originating public keys correctly 
trusted, new fragment requests still sign cluster `0`; the receiving BE 
verifies its actual heartbeat cluster ID and rejects them with 
`NOT_AUTHORIZED`. Same-node upgrades preserve backend IDs, so 
`RemoteOlapTable.invalidateBackendsIfNeed()` does not invalidate topology, and 
its expire-after-access cache can keep this state indefinitely under continued 
queries. Refresh an omitted/unknown destination identity rather than caching it 
permanently, and cover an old-to-new remote metadata transition while the 
originating FE stays running.



##########
fe/fe-core/src/main/java/org/apache/doris/rpc/FrontendRpcKeyRegistration.java:
##########
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.rpc;
+
+import org.apache.doris.catalog.Env;
+import org.apache.doris.system.Backend;
+import org.apache.doris.system.Frontend;
+import org.apache.doris.thrift.TNetworkAddress;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.function.BooleanSupplier;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+/** Keeps query listeners closed until heartbeat publication and worker key 
registration complete. */
+public final class FrontendRpcKeyRegistration {
+    private FrontendRpcKeyRegistration() {
+    }
+
+    public static void awaitPublication() throws IOException, 
InterruptedException {
+        String key = InternalRpcRequestSigner.getInstance().getPublicKey();
+        BackendServiceProxy proxy = BackendServiceProxy.getInstance();
+        // Zero is the uninitialized heartbeat position, so it cannot 
acknowledge a startup.
+        long journalFence = Math.max(1, 
Env.getCurrentEnv().getReplayedJournalId());
+        awaitPublication(() -> 
Env.getCurrentSystemInfo().getAllClusterBackendsNoException().values(),
+                backend -> proxy.isFrontendKeyRegistered(
+                        new TNetworkAddress(backend.getHost(), 
backend.getBrpcPort()), key),
+                () -> isHeartbeatPublished(journalFence), 120_000);

Review Comment:
   [P2] Allow startup publication to span the heartbeat interval
   
   The fixed 120-second deadline can expire before a valid configured heartbeat 
round. For example, with `heartbeat_interval_second=180`, add a fresh observer 
on another host just after the master finishes a round and let it finish 
initialization within 60 seconds. Its local membership entry has no heartbeat 
acknowledgment yet, so `isHeartbeatPublished()` stays false until the next 
round, even with no BEs. This wait throws before that round, and 
`DorisFE.start()` catches the exception and exits before opening HTTP/SQL 
listeners. Account for the configured heartbeat cadence in the publication 
deadline (or trigger publication directly), and cover startup with an interval 
longer than 120 seconds.



-- 
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