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

Delete database API #12765

Merged
merged 4 commits into from
Apr 2, 2024
Merged

Delete database API #12765

merged 4 commits into from
Apr 2, 2024

Conversation

shounakmk219
Copy link
Collaborator

@shounakmk219 shounakmk219 commented Apr 1, 2024

Description

API to delete the given database which effectively deletes all the tables under the given database.
The API has a sync behaviour which means partial database deletion is possible in case of failures.
Server side failures are handled silently and further table deletion is resumed. The response will have appropriate information regarding the tables that failed to delete.

Endpoint : /databases/<databaseName>
Query param : dryRun , required = true
Method : DELETE
Sample output :

{
  "dryRun": false,
  "deletedTables": [
    "db1.table1_REALTIME"
  ],
  "failedTables": [
    {
      "tableName": "db1.table2_OFFLINE",
      "errorMessage": "Error message"
    }
  ]
}

As the API is of idempotent nature client can repeatedly call the API in-case there are tables with failed deletion

labels

feature release-notes

release-notes

API to delete database and all its underlying tables

@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 37 lines in your changes are missing coverage. Please review.

Project coverage is 34.92%. Comparing base (59551e4) to head (38ef740).
Report is 195 commits behind head on master.

Files Patch % Lines
...er/api/resources/PinotDatabaseRestletResource.java 0.00% 37 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #12765       +/-   ##
=============================================
- Coverage     61.75%   34.92%   -26.84%     
+ Complexity      207        6      -201     
=============================================
  Files          2436     2386       -50     
  Lines        133233   131078     -2155     
  Branches      20636    20268      -368     
=============================================
- Hits          82274    45775    -36499     
- Misses        44911    82004    +37093     
+ Partials       6048     3299     -2749     
Flag Coverage Δ
custom-integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration <0.01% <0.00%> (-0.01%) ⬇️
integration1 ?
integration2 ?
java-11 34.92% <0.00%> (-26.79%) ⬇️
java-21 ?
skip-bytebuffers-false 46.67% <ø> (-15.08%) ⬇️
skip-bytebuffers-true ?
temurin 34.92% <0.00%> (-26.84%) ⬇️
unittests 46.67% <ø> (-15.08%) ⬇️
unittests1 46.67% <ø> (-0.22%) ⬇️
unittests2 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 97 to 103
} catch (Exception e) {
if (isSchemaDeleted) {
LOGGER.error("Failed to delete table {}", table);
} else {
LOGGER.error("Failed to delete table and schema for {}", table);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the result should contain the list the tables and schemas that were not deleted and ideally a short message indicating why.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point. Will add that info to the response payload.

Comment on lines 78 to 80
@ApiParam(value = "Run in dryRun mode initially to know the list of tables that will be deleted in actual run. "
+ "No tables will be deleted when dryRun=true", required = true)
@QueryParam("dryRun") boolean dryRun) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we define the default value to be true? It would be great if by default it is dryRun so the UI will mark it by default and users would need to actively turn it off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, made the change 👍

@gortiz gortiz merged commit 2904ceb into apache:master Apr 2, 2024
18 of 19 checks passed
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.

3 participants