vinishjail97 commented on code in PR #894:
URL: https://github.com/apache/incubator-xtable/pull/894#discussion_r4168580388
##########
xtable-api/src/main/java/org/apache/xtable/model/metadata/TableSyncMetadata.java:
##########
@@ -46,6 +47,10 @@ public class TableSyncMetadata {
new ObjectMapper()
.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
+ // A reader on an older version has to tolerate fields a newer
writer added, since this
+ // blob is persisted in target-table metadata and is read back by
whichever version
+ // happens to open the table next.
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
Review Comment:
Thanks for turning this off. Would a small case in `TestTableSyncMetadata`
that parses a version-0 payload carrying an unknown field be reasonable? It is
the only thing that keeps this setting from regressing.
##########
xtable-hudi-support/xtable-iceberg-pluggable-tf/src/main/java/org/apache/xtable/timeline/IcebergRollbackExecutor.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.xtable.timeline;
+
+import lombok.SneakyThrows;
+import lombok.extern.log4j.Log4j2;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.InstantComparison;
+import org.apache.hudi.common.table.timeline.dto.InstantDTO;
+
+import org.apache.iceberg.Table;
+import org.apache.iceberg.catalog.TableIdentifier;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+import org.apache.xtable.iceberg.IcebergConversionTarget;
+import org.apache.xtable.iceberg.IcebergTableManager;
+import org.apache.xtable.model.InternalTable;
+import org.apache.xtable.model.metadata.TableSyncMetadata;
+
+@Log4j2
+public class IcebergRollbackExecutor {
+ private static final ObjectMapper MAPPER =
+ new ObjectMapper()
+ .registerModule(new JavaTimeModule())
+ .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ private final HoodieTableMetaClient metaClient;
+ private final IcebergConversionTarget target;
+ private final IcebergTableManager tableManager;
+
+ public IcebergRollbackExecutor(HoodieTableMetaClient metaClient,
IcebergConversionTarget target) {
+ this.metaClient = metaClient;
+ this.target = target;
+ this.tableManager =
+ IcebergTableManager.of(
+ (org.apache.hadoop.conf.Configuration)
metaClient.getStorageConf().unwrap());
+ }
+
+ @SneakyThrows
+ public void rollbackSnapshot(InternalTable internalTable, HoodieInstant
instantToRollback) {
+ TableIdentifier tableIdentifier =
+ TableIdentifier.of(metaClient.getTableConfig().getTableName());
+ if (tableManager.tableExists(null, tableIdentifier,
metaClient.getBasePath().toString())) {
+ Table table =
+ tableManager.getTable(null, tableIdentifier,
metaClient.getBasePath().toString());
+ TableSyncMetadata syncMetadata =
+ TableSyncMetadata.fromJson(
+
table.currentSnapshot().summary().get(TableSyncMetadata.XTABLE_METADATA))
+ .get();
+ HoodieInstant latestHoodieInstantInIceberg =
+ InstantDTO.toInstant(
+
MAPPER.readValue(syncMetadata.getLatestTableOperationIdentifier(),
InstantDTO.class),
+ metaClient.getInstantGenerator());
+ if (latestHoodieInstantInIceberg.equals(instantToRollback)) {
+ // The instant to rollback is committed in iceberg, so rollback to
previous snapshot.
+ // NOTE: This is equivalent to hudi restore and should be performed by
killing all active
+ // writers.
+ target.beginSync(internalTable);
+ target.rollbackToSnapshotId(table.currentSnapshot().snapshotId());
Review Comment:
I think this leaves Iceberg pointing at files Hudi has deleted: `rollbackTo`
gets the current snapshot's own id, and `completedRollback` then commits an
empty diff. A local IT (insert, insert, `table.rollback(c2)`) shows Iceberg
still planning 2 files after the rollback, 1 of them gone from storage.
Would it work to bring back the parent-snapshot form from 1bfbdd80, or to
throw here until the follow-up lands so the divergence fails loudly? I would
see this as blocking, since an Iceberg reader fails on its next scan.
--
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]