yuqi1129 commented on code in PR #9574:
URL: https://github.com/apache/gravitino/pull/9574#discussion_r2659446497
##########
core/src/main/java/org/apache/gravitino/metalake/MetalakeManager.java:
##########
@@ -367,25 +369,43 @@ public void enableMetalake(NameIdentifier ident) throws
NoSuchMetalakeException
() -> {
try {
boolean inUse = metalakeInUse(store, ident);
- if (!inUse) {
- store.update(
- ident,
- BaseMetalake.class,
- EntityType.METALAKE,
- metalake -> {
- BaseMetalake.Builder builder =
newMetalakeBuilder(metalake);
-
- Map<String, String> newProps =
- metalake.properties() == null
- ? Maps.newHashMap()
- : Maps.newHashMap(metalake.properties());
- newProps.put(PROPERTY_IN_USE, "true");
- builder.withProperties(newProps);
-
- return builder.build();
- });
+ if (inUse) {
+ return null;
}
+ store.update(
+ ident,
+ BaseMetalake.class,
+ EntityType.METALAKE,
+ metalake -> {
+ BaseMetalake.Builder builder = newMetalakeBuilder(metalake);
+
+ Map<String, String> newProps =
+ metalake.properties() == null
+ ? Maps.newHashMap()
+ : Maps.newHashMap(metalake.properties());
+ newProps.put(PROPERTY_IN_USE, "true");
+ builder.withProperties(newProps);
+
+ return builder.build();
+ });
+
+ // The only problem is that we can't make sure we can change all
catalog properties
+ // in a transaction. If any catalog property update fails, the
metalake is already
+ // enabled but catalog properties remain inconsistent.
Review Comment:
When we try to update a property using the following code
```java
GravitinoEnv.getInstance()
.catalogManager()
.alterCatalog(
catalogEntity.nameIdentifier(),
CatalogChange.setProperty(Catalog.PROPERTY_METALAKE_IN_USE, "true"));
```
There are already logs about the identifier, and the case is that if anyone
fails, the whole operation will stop. By the way, I can add some logs to mark
which has succeeded.
--
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]