Caideyipi commented on code in PR #18396: URL: https://github.com/apache/iotdb/pull/18396#discussion_r3734760725
########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/subtask/processor/PipeProcessorSubtaskYieldException.java: ########## @@ -0,0 +1,53 @@ +/* + * 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.iotdb.db.pipe.agent.task.subtask.processor; + +/** Internal control-flow exception that immediately yields the current processor worker. */ +public final class PipeProcessorSubtaskYieldException extends RuntimeException { + + private static final PipeProcessorSubtaskYieldException PAUSE_REQUESTED_INSTANCE = + new PipeProcessorSubtaskYieldException(Reason.PAUSE_REQUESTED); + private static final PipeProcessorSubtaskYieldException PARSER_NOT_ADMITTED_INSTANCE = + new PipeProcessorSubtaskYieldException(Reason.PARSER_NOT_ADMITTED); Review Comment: Yes, the static instances are intentional control-flow sentinels. They disable stack-trace creation because these exceptions are expected pause/yield signals rather than failures; the Reason enum identifies the requested action. A per-throw stack would add allocation cost without diagnostic value. ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/subtask/processor/PipeProcessorSubtask.java: ########## @@ -241,13 +263,20 @@ protected boolean executeOnce() throws Exception { .enrichWithCommitterKeyAndCommitId((EnrichedEvent) event, creationTime, regionId); } decreaseReferenceCountAndReleaseLastEvent(event, shouldReport); + } catch (final PipeProcessorSubtaskYieldException e) { + isResumingFromYield.set(true); + throw e; } catch (final PipeRuntimeOutOfMemoryCriticalException e) { PipeLogger.log( LOGGER::info, DataNodePipeMessages.TEMPORARILY_OUT_OF_MEMORY_IN_PIPE_EVENT_PROCESSING, e.getMessage()); return false; } catch (final Exception e) { + if (ExceptionUtils.getRootCause(e) instanceof PipeProcessorSubtaskYieldException) { + isResumingFromYield.set(true); + throw (PipeProcessorSubtaskYieldException) ExceptionUtils.getRootCause(e); + } if (ExceptionUtils.getRootCause(e) instanceof PipeRuntimeOutOfMemoryCriticalException) { Review Comment: Addressed in 29513e2595a: the exception root cause is now computed once and reused for both control-flow checks, avoiding repeated traversal. -- 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]
