Gabriel39 commented on code in PR #70869:
URL: https://github.com/apache/doris/pull/70869#discussion_r4738502862
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergRestSchemaCompatibility.java:
##########
@@ -63,7 +68,49 @@ static ObjectMapper objectMapper() {
return mapper;
}
+ static void commitWithFormatFence(TableOperations operations,
TableMetadata base, TableMetadata updated,
+ int admittedFormat) {
+ WriteFormat previous = WRITE_FORMAT.get();
+ // The SDK serializes REST requests synchronously on this committing
thread.
+ WRITE_FORMAT.set(new WriteFormat(base.uuid(), admittedFormat));
+ try {
+ operations.commit(base, updated);
+ } finally {
+ if (previous == null) {
+ WRITE_FORMAT.remove();
+ } else {
+ WRITE_FORMAT.set(previous);
+ }
+ }
+ }
+
+ private static UpdateTableRequest withWriteFormat(UpdateTableRequest
request) {
+ WriteFormat format = WRITE_FORMAT.get();
+ if (format == null ||
request.requirements().stream().noneMatch(requirement ->
+ requirement instanceof UpdateRequirement.AssertTableUUID
+ && ((UpdateRequirement.AssertTableUUID)
requirement).uuid().equalsIgnoreCase(format.uuid))) {
+ return request;
+ }
+ List<MetadataUpdate> updates = new
ArrayList<>(request.updates().size() + 1);
+ // REST requirements do not fence format. An explicit same-version
upgrade is a no-op on that version,
+ // but atomically rejects a server-side upgrade because the format
cannot be downgraded.
+ updates.add(new MetadataUpdate.UpgradeFormatVersion(format.version));
Review Comment:
Fixed in e8d37bbf94f9cf968d9535a62e92f1d5187dfcd6.
The REST format fence is now explicitly controlled by
iceberg.rest.enable-format-version-fence, default false. Default V1-V3
single-table and transaction requests retain their original actions and
data-write privilege requirements. Enabling the option adds the atomic
same-version fence and may require metadata/DDL privileges; concurrent REST
format changes during writes remain unsupported while disabled. An existing
matching UpgradeFormatVersion is reused. SDK-backed tests cover default request
equivalence, duplicate prevention, enabled atomic rejection, concurrent scopes
and schema high-water compatibility.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergScanPlanProvider.java:
##########
@@ -2237,6 +2240,46 @@ private static TFileFormatType
deleteFileFormat(FileFormat format) {
return null;
}
+ /** Resolve table-relative physical locations before storage-scheme
normalization. */
+ private UnaryOperator<String> newUriNormalizer(Table table, Map<String,
String> vendedToken) {
+ UnaryOperator<String> normalize = newUriNormalizer(vendedToken);
+ // Metadata-table properties omit the format version; native
delete-table ranges use the base version.
+ Table base = table instanceof BaseMetadataTable ? ((BaseMetadataTable)
table).table() : table;
+ if (getFormatVersion(base) < 4) {
+ return normalize;
+ }
+ FileIO io = table.io();
+ // Reuse the bound view: nesting relative resolvers would rebase
filesystem-rooted manifest version probes.
+ IcebergV4FileIO paths = io instanceof IcebergV4FileIO
Review Comment:
Fixed in e8d37bbf94f9cf968d9535a62e92f1d5187dfcd6.
All listed read paths now find the bound V4 resolver through Delegating
decorators, including cache preparation/probes, native URI normalization,
snapshot wrapping and compact metadata task preparation. Vended credentials
unwrap the shared Delegating contract as well. Regression tests reproduce
decorated-view nesting, unprepared cache hits, lost credentials and task
serialization failures on the old code; the corrected paths pass, including the
JNI cases.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/iceberg/ManifestReaderAccess.java:
##########
@@ -20,30 +20,121 @@
import org.apache.iceberg.avro.AvroIterable;
import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.parquet.ManifestMetadataAccess;
+import org.apache.iceberg.types.Types;
import org.apache.iceberg.util.JsonUtil;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.doris.connector.iceberg.IcebergV4FileIO;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
/** Package bridge for filtering borrowed manifest entries before copying
retained files. */
public final class ManifestReaderAccess {
private ManifestReaderAccess() {
}
+ /** Freeze each transported task's actual reference instead of serializing
table-wide read history. */
+ public static FileScanTask prepareTask(FileScanTask task) {
+ if (task instanceof BaseFilesTable.ManifestReadTask) {
+ BaseFilesTable.ManifestReadTask files =
(BaseFilesTable.ManifestReadTask) task;
+ if (files.io() instanceof IcebergV4FileIO) {
+ return new
BaseFilesTable.ManifestReadTask(files.dataTableSchema(),
+ ((IcebergV4FileIO)
files.io()).forManifest(files.manifest()), files.specsById(),
+ files.manifest(), files.projection(),
files.residual());
+ }
+ } else if (task instanceof BaseEntriesTable.ManifestReadTask) {
+ BaseEntriesTable.ManifestReadTask entries =
(BaseEntriesTable.ManifestReadTask) task;
+ if (entries.io() instanceof IcebergV4FileIO) {
+ return new
BaseEntriesTable.ManifestReadTask(entries.dataTableSchema(),
+ ((IcebergV4FileIO)
entries.io()).forManifest(entries.manifest()), entries.specsById(),
+ entries.manifest(), entries.projection(),
entries.residual());
+ }
+ } else if (task instanceof AllManifestsTable.ManifestListReadTask) {
+ AllManifestsTable.ManifestListReadTask lists =
(AllManifestsTable.ManifestListReadTask) task;
+ if (lists.io() instanceof IcebergV4FileIO) {
+ return new
AllManifestsTable.ManifestListReadTask(lists.dataTableSchema(),
+ ((IcebergV4FileIO) lists.io()).forManifestList(
+ lists.manifestList(),
lists.referenceSnapshotId()),
+ lists.schema(), lists.specsById(),
lists.manifestList(), lists.residual(),
+ lists.referenceSnapshotId());
+ }
+ }
+ return task;
+ }
+
+ /** Metadata-only probes must not decode unused partitions or require
their expired source schemas. */
+ public static ManifestReader<DataFile> readDataMetadata(ManifestFile
manifest, Table table, List<String> columns) {
Review Comment:
Fixed in e8d37bbf94f9cf968d9535a62e92f1d5187dfcd6.
Removed both unreferenced metadata-reader helpers and their unused import.
The connector and related JNI tests compile and pass without them.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorTransaction.java:
##########
@@ -471,12 +478,14 @@ public TableMetadata refresh() {
public void commit(TableMetadata base, TableMetadata metadata) {
IcebergEncryptionRead.checkWrite(base);
IcebergEncryptionRead.checkWrite(metadata);
- // The SDK refreshes on every commit attempt; its CAS rejects
concurrent encryption changes.
- // Keep the stronger published-file identity check only for
writers that already require it.
+ checkFormat(base);
+ checkFormat(metadata);
+ // REWRITE needs the final refresh too, even though it has no
pinned schema context.
+ TableMetadata refreshedMetadata = Preconditions.checkNotNull(
Review Comment:
Fixed in e8d37bbf94f9cf968d9535a62e92f1d5187dfcd6.
Removed the additional refresh from context-free rewrite commits and
synchronous procedure commits. Schema, identity and snapshot fences retain
their required refreshes; CAS retries still validate the admitted format.
Comparative SDK controls reproduce the extra RPC before the fix and now observe
identical refresh counts. Review also found and fixed staged-metadata cleanup
after definite format refusal, plus post-success procedure events/expiration
cleanup after a concurrent upgrade. Deterministic tests verify both refused and
successful publication paths.
--
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]