hello-stephen commented on code in PR #71239:
URL: https://github.com/apache/doris/pull/71239#discussion_r4795598290


##########
docker/thirdparties/docker-compose/iceberg/encryption/README.md:
##########
@@ -38,9 +38,71 @@ metadata remains readable independently of encrypted 
data/equality files.
 `enable_encryption_read=true`, and authenticated private RPC on capable FE/BE
 nodes. It runs both HMS and REST catalogs over the same physical fixtures and
 compares SQL against SDK/Spark history and the eight delete-key modes,
-with cache, COUNT pushdown, batch planning and pruning toggles. Encrypted JNI
-metadata tables remain explicitly unsupported; native position-deletes use the
-protected reader path.
+with cache, COUNT pushdown, batch planning and pruning toggles. Encrypted 
metadata

Review Comment:
   [P3] Document the child cluster and package prerequisite
   
   The enabled SQL suites launch their own TLS/PME child through 
`withIcebergEncryptionCluster`. Following the current deployment instructions 
on the runner’s cluster can make the default-off suite’s REST v3 seed inserts 
fail with `REST_ENCRYPTION_FENCE_UNAVAILABLE`. Document the local Linux FE/BE 
packages and the `icebergEncryptionPackageHome` override here and in the 
connector runbook, and clarify that the fixture configures TLS and PME in the 
child.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/split/SplitAssignment.java:
##########
@@ -91,12 +127,24 @@ private AssignmentQueue(int capacity) {
             this.capacity = capacity;
         }
 
+        private long bytes(List<TScanRangeLocations> batch, int index) {
+            return batch instanceof SizedRanges ? ((SizedRanges) 
batch).bytes[index]
+                    : FileScanRangeSize.bytes(batch.get(index));
+        }
+
         synchronized int offer(List<TScanRangeLocations> batch, int offset) {
             Preconditions.checkArgument(!batch.isEmpty() && offset >= 0 && 
offset < batch.size(),
                     "Invalid split batch offset: %s", offset);
-            int accepted = stopped ? 0 : Math.min(batch.size() - offset, 
capacity - splits.size());
-            for (int i = offset; i < offset + accepted; i++) {
-                splits.addLast(batch.get(i));
+            int accepted = 0;
+            while (!stopped && accepted < batch.size() - offset && 
splits.size() < capacity) {
+                int index = offset + accepted;
+                long weight = bytes(batch, index);
+                if (!splits.isEmpty() && weight > 
FileScanRangeSize.MAX_QUEUE_BYTES - queuedBytes) {

Review Comment:
   [P2] Bound bytes before staging a lazy producer batch
   
   The 32 MiB limit applies only after 
`PluginDrivenScanNode.createStreamingBatchSource` has pulled a count-sized 
batch and `SplitProducer` has started converting it. An encrypted `$files` scan 
can emit one task per valid 2 MiB metadata row. With both split counts set to 
1,024, the producer can retain about 2.7 GiB of distinct Base64 payloads before 
its first queue offer or readiness notification. Apply a byte limit as the 
source is drained and cover this through the producer, where the backlog forms.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/split/FileScanRangeCompactor.java:
##########
@@ -133,4 +140,24 @@ private static boolean canMerge(TFileScanRange left, 
TFileScanRange right) {
         return !left.isSetSplitSource() && !right.isSetSplitSource()
                 && Objects.equals(left.getParams(), right.getParams());
     }
+
+    private static TScanRange copyRangeList(TScanRange original) {
+        TExternalScanRange external = original.getExtScanRange();
+        TFileScanRange files = external.getFileScanRange();
+        TFileScanRange copy = shallowCopy(files, new TFileScanRange(), 
TFileScanRange._Fields.values());
+        // Only this list is mutated. Deep-copying its immutable descriptors 
rematerializes shared file keys.
+        copy.setRanges(new ArrayList<>(files.getRanges()));

Review Comment:
   [P2] Bound eager fragment serialization for wide keyed files
   
   Compaction now shares the key map in memory, but the initial fragment still 
serializes a complete map for every range. With batch mode off, one BE and one 
FE range per row group, a supported file with 64 independently keyed columns, 
1,024 row groups and 32-byte keys sends 2 GiB of key values alone. 
`PipelineExecutionTaskBuilder` sends the whole fragment through 
`TFastSerializer`’s single Java byte array, so it fails before dispatch. Share 
the keys on the wire or bound keyed range fan-out before eager serialization.



##########
be/src/format_v2/table_reader.cpp:
##########
@@ -1937,60 +1937,62 @@ Status TableReader::_parse_delete_predicates(const 
SplitReadOptions& options) {
     
RETURN_IF_ERROR(_parse_deletion_vector_file(options.current_range.table_format_params,
 &desc,
                                                 &has_delete_file));
     if (has_delete_file) {
-        DORIS_CHECK(options.cache != nullptr);
         Status create_status = Status::OK();
 
         bool decoded_cache_hit = false;
-        _deletion_vector = options.cache->get<DeletionVector>(
-                desc.key,
-                [&]() -> std::shared_ptr<DeletionVector> {
-                    auto deletion_vector = std::make_shared<DeletionVector>();
-
-                    DeletionVectorReader dv_reader(_runtime_state, 
_scanner_profile, *_scan_params,
-                                                   desc, _io_ctx.get());
-                    create_status = dv_reader.open();
-                    if (!create_status.ok()) [[unlikely]] {
-                        return nullptr;
-                    }
-
-                    
DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.io_error", {
-                        create_status =
-                                Status::IOError("injected format v2 deletion 
vector read failure");
-                        return nullptr;
-                    });
-                    
DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.should_stop", {
-                        create_status = Status::EndOfFile("stop read.");
-                        return nullptr;
-                    });
-                    std::vector<char> buffer;
-                    if (desc.format == DeleteFileDesc::Format::PAIMON) {
-                        create_status = 
read_paimon_deletion_vector_buffer(dv_reader, desc, buffer);
-                    } else {
-                        buffer.resize(desc.size);
-                        create_status = dv_reader.read_at(desc.start_offset,
-                                                          {buffer.data(), 
buffer.size()});
-                    }
-                    const auto& file_cache_stats = 
dv_reader.file_cache_statistics();
-                    COUNTER_UPDATE(_profile.dv_file_cache_hit_count,
-                                   file_cache_stats.num_local_io_total);
-                    COUNTER_UPDATE(_profile.dv_file_cache_miss_count,
-                                   file_cache_stats.num_remote_io_total);
-                    COUNTER_UPDATE(_profile.dv_file_cache_peer_read_count,
-                                   file_cache_stats.num_peer_io_total);
-                    if (!create_status.ok()) [[unlikely]] {
-                        return nullptr;
-                    }
-
-                    SCOPED_TIMER(_profile.parse_delete_file_time);
-                    create_status = parse_deletion_vector(buffer.data(), 
buffer.size(), desc.format,
-                                                          
deletion_vector.get());
-                    if (!create_status.ok()) [[unlikely]] {
-                        return nullptr;
-                    }
-                    COUNTER_UPDATE(_profile.num_delete_rows, 
deletion_vector->cardinality());
-                    return deletion_vector;
-                },
-                &decoded_cache_hit);
+        const auto load = [&]() -> std::shared_ptr<DeletionVector> {
+            auto deletion_vector = std::make_shared<DeletionVector>();
+
+            DeletionVectorReader dv_reader(_runtime_state, _scanner_profile, 
*_scan_params, desc,
+                                           _io_ctx.get());
+            create_status = dv_reader.open();
+            if (!create_status.ok()) [[unlikely]] {
+                return nullptr;
+            }
+
+            DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.io_error", {
+                create_status = Status::IOError("injected format v2 deletion 
vector read failure");
+                return nullptr;
+            });
+            DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.should_stop", {
+                create_status = Status::EndOfFile("stop read.");
+                return nullptr;
+            });
+            std::vector<char> buffer;
+            if (desc.format == DeleteFileDesc::Format::PAIMON) {
+                create_status = read_paimon_deletion_vector_buffer(dv_reader, 
desc, buffer);
+            } else {
+                buffer.resize(desc.size);
+                create_status =
+                        dv_reader.read_at(desc.start_offset, {buffer.data(), 
buffer.size()});
+            }
+            const auto& file_cache_stats = dv_reader.file_cache_statistics();
+            COUNTER_UPDATE(_profile.dv_file_cache_hit_count, 
file_cache_stats.num_local_io_total);
+            COUNTER_UPDATE(_profile.dv_file_cache_miss_count, 
file_cache_stats.num_remote_io_total);
+            COUNTER_UPDATE(_profile.dv_file_cache_peer_read_count,
+                           file_cache_stats.num_peer_io_total);
+            if (!create_status.ok()) [[unlikely]] {
+                return nullptr;
+            }
+
+            SCOPED_TIMER(_profile.parse_delete_file_time);
+            create_status = parse_deletion_vector(buffer.data(), 
buffer.size(), desc.format,
+                                                  deletion_vector.get());
+            if (!create_status.ok()) [[unlikely]] {
+                return nullptr;
+            }
+            COUNTER_UPDATE(_profile.num_delete_rows, 
deletion_vector->cardinality());
+            return deletion_vector;
+        };
+        // A decoded path/range cache hit cannot authenticate this statement's 
independent DV key.
+        // The disk-backed File Cache remains eligible because it stores only 
ciphertext.
+        if (desc.encryption_info != nullptr) {

Review Comment:
   [P2] Reuse authenticated blocks across vectors in the same Puffin
   
   Each keyed DV opens a new `DeletionVectorReader`. Even when the SDK packed 
several vectors into the same Puffin, each reader fetches and decrypts its 
entire AGS1 block. A scan of 1,000 small DVs inside one full 1 MiB block can 
process roughly 1 GiB for that block. A warm File Cache still repeats 
decryption. Reuse authenticated blocks within the query using the Puffin object 
and its encryption identity, and add a test that checks the read count for 
vectors sharing a block.



##########
fe/fe-iceberg-common/src/main/java/org/apache/doris/connector/iceberg/IcebergV4FileIO.java:
##########
@@ -238,18 +252,19 @@ private synchronized LoadingCache<Long, MetadataHeader> 
snapshots() {
             snapshotHeaders = Caffeine.newBuilder().maximumSize(256).build(id 
-> {
                 Snapshot snapshot = metadata == null ? null : 
metadata.snapshot(id);
                 String path = snapshot == null ? null : 
snapshot.manifestListLocation();
-                return path == null ? null : snapshotHeader(path, id);
+                return path == null ? null : 
snapshotHeader(DorisRelocatedFiles.manifestList(snapshot), id);
             });
         }
         return snapshotHeaders;
     }
 
-    private MetadataHeader snapshotHeader(String path, long snapshotId) {
+    private MetadataHeader snapshotHeader(ManifestListFile file, long 
snapshotId) {
+        String path = file.location();
         String relative = hasBase() || isAbsolute(path) ? 
resolve(tableLocation, path) : null;
         MetadataHeader header = null;
         RuntimeIOException nonAvroCandidate = null;
         try {
-            header = relative == null ? null : existingAvroHeader(relative);
+            header = relative == null ? null : existingAvroHeader(file, 
relative);

Review Comment:
   [P2] Try the valid rooted manifest list for an encrypted v3 snapshot
   
   `rootedLegacyListIgnoresNonAvroRelativeCandidate` covers a v3-to-v4 upgrade 
with an unrelated object at the table-relative spelling of a rooted list. For 
an encrypted list, the typed open checks the AGS1 stream before Avro sees any 
bytes. A short object or invalid AGS1 header fails outside the 
`InvalidAvroMagicException` branch, so the valid rooted list is never tried. 
Let a definitive format mismatch reach the rooted probe and require that the 
rooted list authenticate and match the legacy version and snapshot. [Iceberg 
stream 
open](https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/core/src/main/java/org/apache/iceberg/encryption/AesGcmInputFile.java#L62-L68)
 · [Iceberg AGS1 header 
check](https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/core/src/main/java/org/apache/iceberg/encryption/AesGcmInputStream.java#L64-L77)



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