File tree Expand file tree Collapse file tree
iotdb-core/datanode/src/main/java/org/apache/iotdb/db
execution/operator/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -222,11 +222,17 @@ private void prepareSchemaNodeIteratorForSerialize() {
222222 schemaNodeIteratorForSerialize = schemaTree .getIteratorForSerialize ();
223223 baos = new PublicBAOS (DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES + EXTRA_SIZE_TO_AVOID_GROW );
224224 if (operatorContext != null ) {
225- schemaTreeMemCost = schemaTree .ramBytesUsed ();
225+ long ramBytesUsed = schemaTree .ramBytesUsed ();
226226 operatorContext
227227 .getInstanceContext ()
228228 .getMemoryReservationContext ()
229- .reserveMemoryCumulatively (schemaTreeMemCost );
229+ .reserveMemoryCumulatively (ramBytesUsed );
230+ // For temporary and independently counted memory, we need process it immediately
231+ operatorContext
232+ .getInstanceContext ()
233+ .getMemoryReservationContext ()
234+ .reserveMemoryImmediately ();
235+ this .schemaTreeMemCost = ramBytesUsed ;
230236 }
231237 } catch (MetadataException e ) {
232238 throw new SchemaExecutionException (e );
Original file line number Diff line number Diff line change @@ -45,7 +45,12 @@ public Analysis analyze(Statement statement) {
4545 long startTime = System .nanoTime ();
4646 AnalyzeVisitor visitor = new AnalyzeVisitor (partitionFetcher , schemaFetcher );
4747 Analysis analysis = null ;
48- context .setReserveMemoryForSchemaTreeFunc (context ::reserveMemoryForFrontEnd );
48+ context .setReserveMemoryForSchemaTreeFunc (
49+ mem -> {
50+ context .reserveMemoryForFrontEnd (mem );
51+ // For temporary and independently counted memory, we need process it immediately
52+ context .reserveMemoryForFrontEndImmediately ();
53+ });
4954 try {
5055 analysis = visitor .process (statement , context );
5156 } finally {
Original file line number Diff line number Diff line change 3131import org .apache .iotdb .db .protocol .session .SessionManager ;
3232import org .apache .iotdb .db .queryengine .common .MPPQueryContext ;
3333import org .apache .iotdb .db .queryengine .common .schematree .ClusterSchemaTree ;
34+ import org .apache .iotdb .db .queryengine .exception .MemoryNotEnoughException ;
3435import org .apache .iotdb .db .queryengine .plan .Coordinator ;
3536import org .apache .iotdb .db .queryengine .plan .analyze .ClusterPartitionFetcher ;
3637import org .apache .iotdb .db .queryengine .plan .execution .ExecutionResult ;
@@ -326,6 +327,8 @@ private void parseFetchedData(
326327 throw new RuntimeException (
327328 new MetadataException ("Failed to fetch schema because of unrecognized data" ));
328329 }
330+ } catch (MemoryNotEnoughException e ) {
331+ throw e ;
329332 } catch (Exception e ) {
330333 throw new RuntimeException (e );
331334 }
Original file line number Diff line number Diff line change @@ -163,7 +163,9 @@ private static TSStatus tryCatchQueryException(Exception e) {
163163 TSStatusCode .QUERY_NOT_ALLOWED , INFO_NOT_ALLOWED_IN_BATCH_ERROR + rootCause .getMessage ());
164164 } else if (t instanceof RootFIPlacementException
165165 || t instanceof ReplicaSetUnreachableException
166- || t instanceof QuerySchemaFetchFailedException ) {
166+ || (t instanceof QuerySchemaFetchFailedException
167+ && ((QuerySchemaFetchFailedException ) t ).getErrorCode ()
168+ != TSStatusCode .QUERY_EXECUTION_MEMORY_NOT_ENOUGH .getStatusCode ())) {
167169 return RpcUtils .getStatus (TSStatusCode .PLAN_FAILED_NETWORK_PARTITION , rootCause .getMessage ());
168170 } else if (t instanceof IoTDBException ) {
169171 return Objects .nonNull (((IoTDBException ) t ).getStatus ())
You can’t perform that action at this time.
0 commit comments