Gabriel39 commented on code in PR #71396:
URL: https://github.com/apache/doris/pull/71396#discussion_r4793463434


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java:
##########
@@ -744,20 +761,33 @@ public void commit() throws UserException {
      */
     @VisibleForTesting
     org.apache.iceberg.Transaction newWriteTransaction() {
-        if (!writeSchemaContext.isPresent()) {
-            return table.newTransaction();
+        return newWriteTransaction(table);
+    }
+
+    private org.apache.iceberg.Transaction newWriteTransaction(Table 
writeTable) {
+        if (!(writeTable instanceof HasTableOperations)) {
+            Preconditions.checkState(!writeSchemaContext.isPresent(),
+                    "Iceberg write table %s does not expose table operations", 
writeTable.name());
+            return writeTable.newTransaction();
+        }
+        TableOperations operations = ((HasTableOperations) 
writeTable).operations();
+        FileIO fileIO = operations.io();
+        if (fileIO instanceof HadoopFileIO) {

Review Comment:
   Fixed in 5f1866a5b245. The adapter now activates only for the exact stock 
HadoopFileIO class with a non-no-op authenticator. Configured subclasses retain 
their descriptor-read and bulk-delete overrides. Two SDK-backed tests exercise 
real typed manifest reads and custom bulk deletion; both reproduced the 
previous failure and now pass. A separate test verifies the actual default 
authenticator reuses the original manifest cache.



##########
regression-test/suites/external_table_p0/kerberos/test_iceberg_hadoop_catalog_kerberos.groovy:
##########
@@ -20,6 +20,7 @@ suite("test_iceberg_hadoop_catalog_kerberos", 
"p0,external,kerberos,external_doc
     if (enabled == null || !enabled.equalsIgnoreCase("true")) {
         return
     }
+    // Exercise SDK HadoopFileIO so asynchronous manifest writes must carry 
catalog authentication.

Review Comment:
   Fixed in 5f1866a5b245. Restored DelegateFileIO for this existing fixture, 
whose snapshot-expiration cleanup runs outside the write-transaction adapter. 
Stock HadoopFileIO write coverage remains in the isolated HMS manifest suite. 
This keeps the maintenance fixture's original behavior while testing the 
intended write boundary separately.



##########
regression-test/suites/external_table_p0/kerberos/test_iceberg_hms_manifest_kerberos.groovy:
##########
@@ -0,0 +1,127 @@
+// 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.
+
+suite("test_iceberg_hms_manifest_kerberos", 
"p0,external,kerberos,external_docker,external_docker_kerberos") {
+    if 
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enableKerberosTest")))
 {
+        return
+    }
+    String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+    String suffix = UUID.randomUUID().toString().replace("-", "").substring(0, 
12)
+    String database = "manifest_auth_${suffix}"
+    def fixtures = [
+        [catalog: "iceberg_manifest_a_${suffix}", realm: "LABS.TERADATA.COM", 
host: "hadoop-master",
+         hmsPort: 9583, hdfsPort: 8520, keytab: "hive-presto-master.keytab"],
+        [catalog: "iceberg_manifest_b_${suffix}", realm: "OTHERREALM.COM", 
host: "hadoop-master-2",
+         hmsPort: 9683, hdfsPort: 8620, keytab: 
"other-hive-presto-master.keytab"]
+    ]
+    String rules = 'RULE:[2:$1@$0](.*@LABS.TERADATA.COM)s/@.*//\n' +
+            'RULE:[2:$1@$0](.*@OTHERREALM.COM)s/@.*//\nDEFAULT'
+    def overwriteModeRows = sql "SHOW VARIABLES LIKE 
'iceberg_partition_overwrite_mode'"
+    String previousOverwriteMode = overwriteModeRows.isEmpty() ? null : 
overwriteModeRows[0][1].toString()
+    Throwable failure = null
+    try {
+        if (previousOverwriteMode != null) {
+            sql "SET iceberg_partition_overwrite_mode = 'dynamic'"
+        }
+        fixtures.each { fixture ->
+            // Keep the SDK HadoopFileIO: DelegateFileIO would mask a 
manifest-worker authentication regression.
+            sql """
+                CREATE CATALOG `${fixture.catalog}` PROPERTIES (
+                    "type" = "iceberg",
+                    "iceberg.catalog.type" = "hms",
+                    "warehouse" = 
"hdfs://${externalEnvIp}:${fixture.hdfsPort}/tmp/iceberg/${database}",
+                    "hive.metastore.uris" = 
"thrift://${externalEnvIp}:${fixture.hmsPort}",
+                    "hive.metastore.sasl.enabled" = "true",
+                    "hive.metastore.kerberos.principal" = 
"hive/${fixture.host}@${fixture.realm}",
+                    "fs.defaultFS" = 
"hdfs://${externalEnvIp}:${fixture.hdfsPort}",
+                    "hadoop.security.authentication" = "kerberos",
+                    "hadoop.kerberos.principal" = 
"hive/presto-master.docker.cluster@${fixture.realm}",
+                    "hadoop.kerberos.keytab" = "/keytabs/${fixture.keytab}",
+                    "hadoop.security.auth_to_local" = "${rules}",
+                    "dfs.namenode.kerberos.principal" = 
"hdfs/${fixture.host}@${fixture.realm}",
+                    "dfs.client.use.datanode.hostname" = "true",
+                    "hadoop.security.token.service.use_ip" = "false",
+                    "dfs.data.transfer.protection" = "authentication",
+                    "meta.cache.iceberg.manifest.enable" = "true"
+                )
+            """
+            sql "CREATE DATABASE `${fixture.catalog}`.`${database}`"
+            sql """
+                CREATE TABLE `${fixture.catalog}`.`${database}`.events (id 
INT, payload STRING)
+                ENGINE = iceberg PROPERTIES ("write-format" = "parquet")
+            """
+        }
+        def tableName = { fixture -> 
"`${fixture.catalog}`.`${database}`.events" }
+        def checkRows = { fixture, expected ->
+            sql "REFRESH TABLE ${tableName(fixture)}"
+            def rows = sql "SELECT id, payload FROM ${tableName(fixture)} 
ORDER BY id"
+            assertEquals(expected, rows.collect { row -> row.collect { value 
-> value.toString() } })
+        }
+        // Alternate realms on the same FE so a shared SDK worker must not 
retain the previous catalog's identity.
+        fixtures.each { fixture -> sql "INSERT INTO ${tableName(fixture)} 
VALUES (1, 'first')" }
+        fixtures.reverseEach { fixture -> sql "INSERT INTO 
${tableName(fixture)} VALUES (2, 'second')" }
+        fixtures.each { fixture -> checkRows(fixture, [["1", "first"], ["2", 
"second"]]) }
+        fixtures.each { fixture ->
+            sql "INSERT OVERWRITE TABLE ${tableName(fixture)} SELECT 3, 
'replacement'"
+            checkRows(fixture, [["3", "replacement"]])
+            def snapshots = sql "SELECT count(*) FROM 
`${fixture.catalog}`.`${database}`.`events\$snapshots`"
+            assertEquals(3L, snapshots[0][0] as long)
+            assertFalse((sql "SELECT * FROM 
`${fixture.catalog}`.`${database}`.`events\$history`").isEmpty())
+            assertFalse((sql "SELECT * FROM 
`${fixture.catalog}`.`${database}`.`events\$manifests`").isEmpty())
+            sql "INSERT OVERWRITE TABLE ${tableName(fixture)} SELECT 4, 
'empty' WHERE 1 = 0"
+            checkRows(fixture, [])
+            // Two new appends and REFRESH expose parallel reads during an 
empty dynamic overwrite.
+            sql "INSERT INTO ${tableName(fixture)} VALUES (5, 
'first-manifest')"
+            sql "INSERT INTO ${tableName(fixture)} VALUES (6, 
'second-manifest')"
+            checkRows(fixture, [["5", "first-manifest"], ["6", 
"second-manifest"]])
+            sql "REFRESH TABLE ${tableName(fixture)}"
+            sql "INSERT OVERWRITE TABLE ${tableName(fixture)} SELECT 7, 
'empty' WHERE 1 = 0"
+            checkRows(fixture, [])
+        }
+    } catch (Throwable error) {
+        failure = error
+        throw error
+    } finally {
+        List<Throwable> cleanupErrors = []
+        fixtures.reverseEach { fixture ->
+            ["DROP TABLE IF EXISTS `${fixture.catalog}`.`${database}`.events",

Review Comment:
   Fixed in 5f1866a5b245. Each fixture now owns an explicit unique namespace 
directory. Runner credentials are checked before any SQL resources are created. 
Finally, an isolated authenticated child JVM recursively deletes that owned 
directory and verifies absence even if SQL teardown fails, preserving the 
primary error. The exact cleanup script/lifecycle passed against real secured 
HDFS with Hadoop 2.8.0, including orphan files, bad credentials, directory 
guards, timeout termination and parent UGI isolation. Full Doris SQL/HMS 
execution remains for CI.



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