diff --git a/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java b/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java index e11408639..9ca8ea4ca 100644 --- a/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java +++ b/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java @@ -211,7 +211,7 @@ private void saveParentChildRelationship(final QualifiedName child, final TableD child, child, parent); delete(child); } catch (Exception deleteException) { - log.error("Fail to deleteTable = {} after failing to save the parent child relationship " + log.error("Fail to deleteTable = {} after failing to update it's parent child relation " + "for child={}, parent={}", child, child, parent, deleteException); } @@ -355,9 +355,15 @@ public TableDto deleteAndReturn(final QualifiedName name, final boolean isMView) try { parentChildRelMetadataService.drop(name); } catch (Exception e) { - log.error("Fail to drop parent child relation for table = {}", name, e); + try { + connectorTableServiceProxy.create(name, converterUtil.fromTableDto(tableDto)); + } catch (Exception tableCreationException) { + log.error("Fail to recreate table={} with tableDto={} " + + "after failing to update it's parent child relation", + name, metacatJson.toJsonString(tableDto), tableCreationException); + } + throw e; } - // If this is a common view, the storage_table if present // should also be deleted. if (MetacatUtils.isCommonView(tableDto.getMetadata()) @@ -541,7 +547,7 @@ public void rename( // rename the parent back if fail to update parent child relation connectorTableServiceProxy.rename(newName, oldName, isMView); } catch (Exception renameException) { - log.error("Fail to rename from {} to {} after failing to save the parent child relationship", + log.error("Fail to rename from {} to {} after failing to update it's parent child relation", oldName, newName, renameException); } throw e;