This is an automated email from the ASF dual-hosted git repository. JackieTien97 pushed a commit to branch rc/2.0.12 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 07a3a220d1721f74f6aa3600b21cec3225e9842a Author: Caideyipi <[email protected]> AuthorDate: Tue Oct 20 10:07:32 2026 +0800 [Pipe] Refresh credential user IDs and retain privilege metadata across retries (#18914) * [Pipe] Refresh pipe user id when credentials change * [Pipe] Preserve TsFile privilege metadata across retries --- .../event/common/tsfile/PipeTsFileInsertionEvent.java | 7 +++---- .../db/pipe/event/PipeTsFileInsertionEventTest.java | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/PipeTsFileInsertionEvent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/PipeTsFileInsertionEvent.java index 98edc06e7fc..91269a9d12c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/PipeTsFileInsertionEvent.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/PipeTsFileInsertionEvent.java @@ -526,6 +526,9 @@ public class PipeTsFileInsertionEvent extends PipeInsertionEvent holderMessage), e); } finally { + // Retries must repeat the privilege check, so release its metadata only with the event. + tableNames = null; + treeSchemaMap = null; if (Objects.nonNull(pipeName)) { try { PipeDataNodeSinglePipeMetrics.getInstance() @@ -765,10 +768,6 @@ public class PipeTsFileInsertionEvent extends PipeInsertionEvent e.getMessage()); LOGGER.warn(errorMsg, e); throw new PipeException(errorMsg, e); - } finally { - // GC useless - tableNames = null; - treeSchemaMap = null; } } diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/PipeTsFileInsertionEventTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/PipeTsFileInsertionEventTest.java index 5d5be1dbade..10f642527dc 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/PipeTsFileInsertionEventTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/PipeTsFileInsertionEventTest.java @@ -80,7 +80,8 @@ public class PipeTsFileInsertionEventTest { TsFileNameGenerator.generateNewTsFilePath( TestConstant.BASE_OUTPUT_PATH + IoTDBConstant.SEQUENCE_FOLDER_NAME, 1, 1, 1, 1)); try { - AuthorityChecker.setAccessControl(new TestAccessControl()); + final TestAccessControl accessControl = Mockito.spy(new TestAccessControl()); + AuthorityChecker.setAccessControl(accessControl); final TsFileResource resource = new TsFileResource(file); try (CompactionTestFileWriter writer = new CompactionTestFileWriter(resource)) { @@ -126,6 +127,18 @@ public class PipeTsFileInsertionEventTest { Long.MIN_VALUE, Long.MAX_VALUE); Assert.assertThrows(AccessDeniedException.class, tableEvent::throwIfNoPrivilege); + // A denied event must remain retryable until SELECT is granted. + Assert.assertThrows(AccessDeniedException.class, tableEvent::throwIfNoPrivilege); + Mockito.doReturn(true) + .when(accessControl) + .checkCanSelectFromTable4Pipe(Mockito.anyString(), Mockito.any(), Mockito.any()); + tableEvent.throwIfNoPrivilege(); + // Processing can fail after a successful check, so the next attempt must check again. + tableEvent.throwIfNoPrivilege(); + Mockito.doReturn(false) + .when(accessControl) + .checkCanSelectFromTable4Pipe(Mockito.anyString(), Mockito.any(), Mockito.any()); + Assert.assertThrows(AccessDeniedException.class, tableEvent::throwIfNoPrivilege); tableEvent.close(); final PipeTsFileInsertionEvent treeEvent = @@ -157,6 +170,8 @@ public class PipeTsFileInsertionEventTest { treeEvent.setTreeSchemaMap(Collections.singletonMap(deviceID, new String[] {"s0", "s1"})); Assert.assertThrows(AccessDeniedException.class, treeEvent::throwIfNoPrivilege); + // Retrying a realtime event must not fall back to the historical coarse filter. + Assert.assertThrows(AccessDeniedException.class, treeEvent::throwIfNoPrivilege); treeEvent.close(); } finally {
