github-actions[bot] commented on code in PR #70899:
URL: https://github.com/apache/doris/pull/70899#discussion_r4667821984


##########
fe/fe-core/src/main/java/org/apache/doris/common/proc/RemoteIndexSchemaProcDir.java:
##########
@@ -59,16 +57,14 @@ public RemoteIndexSchemaProcDir(TableIf table, List<Column> 
schema, Set<String>
     public ProcResult fetchResult() throws AnalysisException {
         Preconditions.checkNotNull(table);
         Preconditions.checkNotNull(schema);
-        List<Tablet> tablets = null;
+        List<Partition> partitions;
         table.readLock();
         try {
-            OlapTable olapTable = (OlapTable) table;
-            // Get sample tablets for remote desc schema
-            tablets = 
olapTable.getSampleTablets(ConnectContext.get().getSessionVariable().maxFetchRemoteTabletCount);
+            partitions = new ArrayList<>(((OlapTable) table).getPartitions());

Review Comment:
   [P2] Snapshot partition tablets while holding the table lock
   
   This method now copies only `Partition` references under `table.readLock()` 
and unlocks before `fetchPartitions` reads each partition's visible version and 
`baseIndex` tablet list. Schema-change completion replaces 
`Partition.baseIndex` under the table write lock, so a concurrent transition 
can make this request combine visibility from one state with tablets from 
another (or send retired tablet IDs), causing the complete-schema fetch to fail 
or omit paths. Materialize the immutable tablet snapshot while holding the read 
lock, then release the lock before the remote RPC.



##########
fe/fe-core/src/main/java/org/apache/doris/common/util/FetchRemoteTabletSchemaUtil.java:
##########
@@ -63,11 +63,19 @@ public class FetchRemoteTabletSchemaUtil {
     private static final Logger LOG = 
LogManager.getLogger(FetchRemoteTabletSchemaUtil.class);
 
     private final List<Tablet> remoteTablets;
-    private final List<Column> tableColumns;
 
     public FetchRemoteTabletSchemaUtil(List<Tablet> tablets) {
         this.remoteTablets = tablets;
-        this.tableColumns = Lists.newArrayList();
+    }
+
+    public static List<Column> fetchPartitions(List<Partition> partitions) 
throws AnalysisException {
+        List<Tablet> tablets = Lists.newArrayList();
+        for (Partition partition : partitions) {
+            if (partition.getVisibleVersion() > 
Partition.PARTITION_INIT_VERSION) {
+                tablets.addAll(partition.getBaseIndex().getTablets());

Review Comment:
   [P2] Enforce the tablet cap before retaining the full table list
   
   `fetchPartitions` accumulates every tablet from every visible partition, but 
`fetch()` checks `max_fetch_remote_schema_tablet_count` only after this list is 
complete. A table with millions of tablets (and the default limit of 512) 
therefore forces the FE to retain millions of `Tablet` references before 
returning the expected limit error, and can exhaust FE heap. 
Count/short-circuit while enumerating or otherwise keep the collection bounded 
before rejecting oversized requests.



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