Skip to content

Commit 83cc2d8

Browse files
committed
Retry definition metadata updates for vtts updates
1 parent 7841ff6 commit 83cc2d8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/MetacatUtils.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class MetacatUtils {
3232

3333
public static final String ICEBERG_MIGRATION_DO_NOT_MODIFY_TAG = "iceberg_migration_do_not_modify";
3434
public static final String NAME_TAGS = "tags";
35+
private static final String DATA_DEPENDENCY_NODE = "data_dependency";
36+
private static final String VTTS_FIELD = "valid_thru_utc_ts";
3537

3638
/**
3739
* Iceberg common view field names.
@@ -128,6 +130,21 @@ public static Set<String> getTableTags(@Nullable final ObjectNode definitionMeta
128130
return tags;
129131
}
130132

133+
public static long getVtts(final ObjectNode metadata) {
134+
if (metadata == null) {
135+
return -1;
136+
}
137+
JsonNode tmp = metadata.get(DATA_DEPENDENCY_NODE);
138+
if (tmp == null || !tmp.isObject()) {
139+
return -1;
140+
}
141+
JsonNode vttsNode = tmp.get(VTTS_FIELD);
142+
if (vttsNode == null || !vttsNode.canConvertToLong()) {
143+
return -1;
144+
}
145+
return vttsNode.asLong();
146+
}
147+
131148
public static String getIcebergMigrationExceptionMsg(final String requestType,
132149
final String tableName) {
133150
return String.format("%s to hive table: %s are temporarily blocked " +

metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,14 @@ public TableDto updateAndReturn(final QualifiedName name, final TableDto tableDt
684684
log.info("Saving user metadata for table {}", name);
685685
final long start = registry.clock().wallTime();
686686
userMetadataService.saveMetadata(metacatRequestContext.getUserName(), tableDto, true);
687+
final long vtts = MetacatUtils.getVtts(tableDto.getDefinitionMetadata());
688+
if (vtts > 0) {
689+
log.info("Received vtts update for {} to {}", name, vtts);
690+
for (int i = 0; i < 3; i++) {
691+
userMetadataService.saveMetadata(metacatRequestContext.getUserName(), tableDto, true);
692+
}
693+
}
694+
687695
final long duration = registry.clock().wallTime() - start;
688696
log.info("Time taken to save user metadata for table {} is {} ms", name, duration);
689697
registry.timer(registry.createId(Metrics.TimerSaveTableMetadata.getMetricName()).withTags(name.parts()))

0 commit comments

Comments
 (0)