@@ -204,6 +204,7 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized,
204204 int retryMaxTimes = rsList .size ();
205205 int retryTimes = 0 ;
206206 boolean success = false ;
207+ Exception exception = null ;
207208 while (!success && retryTimes < retryMaxTimes ) {
208209 try {
209210 ObServerAddr obServerAddr = rsList .get (retryTimes );
@@ -221,6 +222,7 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized,
221222 "current server addr is invalid but rsList is not updated, ip: {}, sql port: {}" ,
222223 rsList .get (retryTimes ).getIp (), rsList .get (retryTimes ).getSqlPort ());
223224 retryTimes ++;
225+ exception = e ;
224226 } else {
225227 throw e ;
226228 }
@@ -229,14 +231,13 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized,
229231 if (!success ) {
230232 BOOT .error ("all rs servers are not available, rootServerKey:{}, rsList: {}" ,
231233 rootServerKey , rsList );
232- throw new ObTableUnexpectedException ("all rs servers are not available" );
234+ throw new ObTableUnexpectedException ("all rs servers are not available" , exception );
233235 }
234236 List <ReplicaLocation > replicaLocations = tableEntry .getTableLocation ()
235237 .getReplicaLocations ();
236238 BOOT .info ("{} success to get replicaLocation {}" , tableClient .getDatabase (),
237239 objectMapper .writeValueAsString (replicaLocations ));
238240
239- List <Exception > obTableExceptions = new ArrayList <>();
240241 for (ReplicaLocation replicaLocation : replicaLocations ) {
241242 ObServerInfo info = replicaLocation .getInfo ();
242243 ObServerAddr addr = replicaLocation .getAddr ();
@@ -246,55 +247,19 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized,
246247 continue ;
247248 }
248249
249- // 忽略初始化建连失败,否则client会初始化失败,导致应用无法启动的问题
250- // 初始化建连失败(可能性较小),如果后面这台server恢复,数据路由失败,就会重新刷新metadata
251- // 在失败100次后(RUNTIME_CONTINUOUS_FAILURE_CEILING),重新刷新建连
252- // 本地cache 1小时超时后(SERVER_ADDRESS_CACHING_TIMEOUT),重新刷新建连
253- // 应急可以直接observer切主
254250 try {
255251 ObTable obTable = new ObTable .Builder (addr .getIp (), addr .getSvrPort ())
256- //
257252 .setLoginInfo (tableClient .getTenantName (), tableClient .getUserName (),
258253 tableClient .getPassword (), tableClient .getDatabase (),
259254 tableClient .getClientType (runningMode ))
260- //
261255 .setProperties (tableClient .getProperties ())
262256 .setConfigs (tableClient .getTableConfigs ()).setObServerAddr (addr ).build ();
263257 addr2Table .put (addr , obTable );
264258 servers .add (addr );
265259 } catch (Exception e ) {
266- BOOT .warn (
267- "The addr{}:{} failed to put into table roster, the node status may be wrong, Ignore" ,
268- addr .getIp (), addr .getSvrPort ());
269- RUNTIME .warn ("initMetadata meet exception" , e );
270- e .printStackTrace ();
271- // collect exceptions when login
272- obTableExceptions .add (e );
273- }
274- }
275- if (servers .isEmpty ()) {
276- BOOT .error ("{} failed to connect any replicaLocation server: {}" ,
277- tableClient .getDatabase (), objectMapper .writeValueAsString (replicaLocations ));
278- boolean isSameTypeException = true ;
279- int errCode = -1 ;
280- // if collected exceptions are the same type, throw the original exception
281- for (Exception e : obTableExceptions ) {
282- if (!(e instanceof ObTableException )) {
283- isSameTypeException = false ;
284- break ;
285- }
286- int curErrCord = ((ObTableException ) e ).getErrorCode ();
287- if (errCode == -1 ) {
288- errCode = curErrCord ;
289- } else if (errCode != curErrCord ) {
290- isSameTypeException = false ;
291- break ;
292- }
293- }
294- if (isSameTypeException && !obTableExceptions .isEmpty ()) {
295- throw obTableExceptions .get (0 );
260+ BOOT .warn ("initMetadata meet exception" , e );
261+ throw e ;
296262 }
297- throw new Exception ("failed to connect any replicaLocation server" );
298263 }
299264
300265 BOOT .info ("{} success to build server connection {}" , tableClient .getDatabase (),
0 commit comments