Skip to content

Commit 71a8a45

Browse files
committed
Retry definition metadata updates for vtts updates
1 parent 07d4d30 commit 71a8a45

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

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

+13
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ 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+
final Optional<ObjectNode> metadata = userMetadataService.getDefinitionMetadata(tableDto.getName());
691+
if (metadata.isPresent()) {
692+
final long currVtts = MetacatUtils.getVtts(metadata.get());
693+
if (currVtts < vtts) {
694+
log.info("Retrying vtts update for {} from {} to {}", name, currVtts, vtts);
695+
userMetadataService.saveMetadata(metacatRequestContext.getUserName(), tableDto, true);
696+
}
697+
}
698+
}
699+
687700
final long duration = registry.clock().wallTime() - start;
688701
log.info("Time taken to save user metadata for table {} is {} ms", name, duration);
689702
registry.timer(registry.createId(Metrics.TimerSaveTableMetadata.getMetricName()).withTags(name.parts()))

0 commit comments

Comments
 (0)