Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5154] refactor(drop-metalake): re-define drop metalake #5155

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

mchades
Copy link
Contributor

@mchades mchades commented Oct 16, 2024

What changes were proposed in this pull request?

  • Add an in-use property to the metalake with the default value of true.
  • Only empty metalake with in-use=false can be dropped when force=false
  • User can use dorce option to drop metalake
  • More drop metalake limitations please see the JavaDoc of dropMetalake in API module

Why are the changes needed?

Fix: #5154

Does this PR introduce any user-facing change?

yes, users now can not drop an in used metalake

How was this patch tested?

tests added

@mchades
Copy link
Contributor Author

mchades commented Oct 16, 2024

This PR is based on #5067

@mchades mchades self-assigned this Oct 16, 2024
@mchades mchades force-pushed the drop-metalake branch 13 times, most recently from aea5e9b to 53167c9 Compare October 18, 2024 05:00
@mchades mchades marked this pull request as ready for review October 18, 2024 05:01
Comment on lines 190 to 195
ErrorResponse resp =
restClient.get(
API_METALAKES_IDENTIFIER_PATH + name + "/activate",
ErrorResponse.class,
Collections.emptyMap(),
ErrorHandlers.metalakeErrorHandler());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you didn't update the code here for metalake, it should align with catalog to use patch with request body.

NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
checkMetalake(metalakeIdent, store);

if (!getInUseValue(store, ident)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better rename to getCatalogInUseValue for clear understanding.

@@ -116,14 +165,13 @@ public BaseMetalake createMetalake(
NameIdentifier ident, String comment, Map<String, String> properties)
throws MetalakeAlreadyExistsException {
long uid = idGenerator.nextId();
StringIdentifier stringId = StringIdentifier.fromId(uid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ince the uid was already in the metalake entity field and I don't see that uid being used in properties, I removed it.

boolean inUse = metalakeInUse(store, ident);
if (inUse && !force) {
throw new MetalakeInUseException(
"Metalake %s is in use, please deactivate it first or use force option", ident);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable, not deactivate.

Comment on lines 261 to 265
// If reached here, it implies that the metalake is not in use or force is true.
if (inUse) {
// force is true, so deactivate the metalake first.
disableMetalake(ident);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here for metalake, we don't need to disable this before the drop.

@Produces("application/vnd.gravitino.v1+json")
@Timed(name = "activate-metalake." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
@ResponseMetered(name = "activate-metalake", absolute = true)
public Response activateMetalake(@PathParam("name") String metalakeName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still keep this method and the below one?

* Otherwise, a {@link MetalakeInUseException} will be thrown.
* </ul>
*
* It is equivalent to calling {@code dropMetalake(ident, false)}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{@code dropMetalake(name, false)}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jerryshao
Copy link
Contributor

Overall LGTM, just one small comment.

@jerryshao jerryshao merged commit 155c429 into apache:main Oct 21, 2024
26 checks passed
mplmoknijb pushed a commit to mplmoknijb/gravitino that referenced this pull request Nov 6, 2024
…e#5155)

### What changes were proposed in this pull request?

- Add an in-use property to the metalake with the default value of true.
- Only empty metalake with in-use=false can be dropped when
`force=false`
 - User can use `dorce` option to drop metalake
- More drop metalake limitations please see the JavaDoc of
`dropMetalake` in API module

### Why are the changes needed?

Fix: apache#5154 

### Does this PR introduce _any_ user-facing change?

yes, users now can not drop an in used metalake

### How was this patch tested?

tests added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] refine drop metalake semantics and behavior
2 participants