yuqi1129 commented on code in PR #15115:
URL: https://github.com/apache/gravitino/pull/15115#discussion_r4629188246


##########
api/src/main/java/org/apache/gravitino/domain/DomainOperations.java:
##########
@@ -117,11 +117,14 @@ Domain alterDomain(String name, DomainChange... changes)
       throws NoSuchDomainException, DomainAlreadyExistsException, 
IllegalArgumentException;
 
   /**
-   * Deletes a domain. The backing tag and the tags on the member objects are 
kept.
+   * Deletes a draft domain. The backing tag and the tags on the member 
objects are kept. A
+   * published domain must be unpublished first. The status is checked before 
the sub-domains, so
+   * deleting a published domain with sub-domains throws {@link 
IllegalArgumentException}.
    *
    * @param name The name of the domain.
    * @return True if the domain is deleted, false if it does not exist.

Review Comment:
   Could the return contract mention hidden drafts as well? With authorization 
enabled, deleting a draft hidden from the caller returns HTTP 200 with 
`dropped=false` and leaves the domain in place. A cleanup client therefore 
cannot infer absence from `false`. The OpenAPI description already covers this. 
Please carry the same wording into the Java and Python SDK docs and qualify the 
404 entry in the user guide for DELETE.



##########
core/src/test/java/org/apache/gravitino/domain/TestDomainManager.java:
##########
@@ -662,6 +669,31 @@ public void testDeleteDomain() {
     Assertions.assertEquals(0, domainManager.listDomains(METALAKE).length);
   }
 
+  @Test
+  public void testDeleteChecksStatus() {

Review Comment:
   Could we add a regression test for a publish committing while delete waits 
for the row lock? I changed the delete callback in `DomainMetaService` to use 
the pre-lock `domainPO` in place of `lockedDomainPO`. This test still passed, 
although that change would let delete act on a stale DRAFT after publish 
commits. The latch setup in 
`TestDomainMetaService.testDeleteWaitsForConcurrentAlterAndDeletes` looks 
reusable. Hold the publish transaction open, start delete while it can still 
observe DRAFT, then commit publish. Delete should throw 
`IllegalArgumentException`, and a fresh read should still return PUBLISHED.



##########
docs/manage-domains-in-gravitino.md:
##########
@@ -283,8 +283,12 @@ draft = domain.unpublish()
 
 ### Delete a Domain
 
-Delete or detach children before deleting their parent. Members alone do not 
prevent deletion.
-The operation keeps backing tags and object assignments and returns false if 
the domain is absent.
+Only a draft domain can be deleted. Unpublish a published domain first; 
deleting it fails with
+HTTP 400 and `IllegalArgumentException`. Delete or detach children before 
deleting their parent;
+deleting a draft parent with children fails with HTTP 409 and 
`NonEmptyDomainException`. The status

Review Comment:
   Small docs follow-up: could you also update the Delete bullet in 
`design-docs/domain-design.md` under Subdomains? It still lists only the child 
check. A sentence saying that deletion requires DRAFT and that status is 
checked before children would keep the two descriptions in sync. Please also 
align the Markdown source columns in the edited HTTP status table.



-- 
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]

Reply via email to