Skip to content

setting option to enable/disable backup during delete record#8728

Merged
ianwallen merged 6 commits into
geonetwork:mainfrom
wangf1122:main.delete.metadata.without.backup.option
May 12, 2025
Merged

setting option to enable/disable backup during delete record#8728
ianwallen merged 6 commits into
geonetwork:mainfrom
wangf1122:main.delete.metadata.without.backup.option

Conversation

@wangf1122
Copy link
Copy Markdown
Contributor

@wangf1122 wangf1122 commented Apr 4, 2025

The current delete record process will always force to backup the data and do delete after. The issue is if there is very big size attachment (for example over 1tb) with the metadata. The tomcat server will easily get clogged.

So this feature added such option to the setting table

image

It will override or do nothing to the API withbackup parameter. There are three scenarios

  1. When the parameter is not supplied, it is currently defaulted as true. It will remain like this unless the setting is set to ForceNoBackup and this flag will override the withbackup to be false

  2. When the parameter is supplied and set to true, it will remain as true unless the setting is set to ForceNoBackup, therefore it will cause some conflicting error

  3. When the parameter is supplied and set to false, it will remain as false unless the setting is set to ForceBackup, therefore it will cause some conflicting error


this.cancelWorkingCopy = function (md) {
return gnMetadataManager.remove(md.id);
return gnMetadataManager.remove(md.id, gnConfig["metadata.delete.enablebackup"]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The parameter should be system wide and have nothing to do with extra parameters supplied to an api.

i.e. If backup option is disabled, it should not be possible for someone to indicate that they do want a backup by setting the backup flag to true on the api.

Maybe if someone does call the api with the backup option set to true then it should fail if backup option is disabled.

Not sure if the configuration options should be
Backup options

  • Enabled
  • Disabled (Optionally Enabled in API)
  • Disabled

In this case your current PR seem to be implementing "Disabled (Optionally Enabled in API)". But in some case, the option should be completely disabled and no API option exists to perform the backup.

I question a use case where someone would mostly want the backups disabled when deleting records however sometimes want the backup?

@josegar74 - what are your thought on this implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see that the backend service has a default of true (

@Parameter(description = API_PARAM_BACKUP_FIRST, required = false) @RequestParam(required = false, defaultValue = "true") boolean withBackup,
)

Maybe it can be changed like this:

  • If the parameter is provided, use what is provided.
  • If the parameter is not provided, use the new setting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are 3 options

  • Enabled
  • Disabled (Optionally Enabled in API)
  • Disabled

The suggestion that @josegar74 supplied is cleaner than modifying the ui however it still uses the option " Disabled (Optionally Enabled in API)"

In some cases, we may want to completely disable the backup. And if someone supplied withBackup=true then we want it to fail indicating that that feature has been disabled. (This would be the "Disabled" option)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe the configuration options should be the following?

  • Enabled (Default)
  • Disabled (Optionally enabled in API using withBackup=true)
  • Disabled Feature. (Will fail if API attempts to supply withBackup=true)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ianwallen @josegar74

I scan the project and I dont see anywhere it intentionally to pass this parameter. Therefore it was defaulted to true.

I have simplify the logic. Simply allow nullable to this withBackup param. So it will default to the setting value. Otherwise, we will do mismatch checking and throw an error accordingly. It will fit into the scenario that you are describing here. Please take a look of the code.

@ianwallen ianwallen added this to the 4.4.7 milestone Apr 4, 2025
@ianwallen ianwallen requested a review from josegar74 April 4, 2025 11:39
Comment thread services/src/main/java/org/fao/geonet/api/records/MetadataInsertDeleteApi.java Outdated
Comment thread web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v447/migrate-default.sql Outdated
@josegar74 josegar74 modified the milestones: 4.4.7, 4.4.8 Apr 10, 2025
@wangf1122 wangf1122 force-pushed the main.delete.metadata.without.backup.option branch from c081ffb to 1077817 Compare April 11, 2025 21:33
INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('metadata/history/accesslevel', 'Editor', 0, 12021, 'n');

INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('metadata/delete/profilePublishedMetadata', 'Editor', 0, 12011, 'n');
INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('metadata/delete/backupOptions', 'NoPreference', 0, 12012, 'n');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NoPreference is confusing? What does NoPreference? does it mean that a backup will be performed or not be performed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Add what @josegar74 suggested for the name change

@josegar74
Copy link
Copy Markdown
Member

@wangf1122 would not be better like this?

  • Force backup: always makes a backup. Ignores the API parameter.
  • Force no backup: never makes a backup. Ignores the API parameter.
  • Use API parameter (NoPreference, but with a slightly better name, I think):
    • If provided, uses the value provided.
    • If not provided, it makes a backup (current default behaviour).

@wangf1122
Copy link
Copy Markdown
Contributor Author

  • Use API parameter

@josegar74

I have change the name for the option called "Use API parameter" and made the help text description change accordingly

Comment on lines +234 to +243
{{'Force backup' | translate}}
</option>
<option
value="ForceNoBackup"
ng-selected="'ForceNoBackup' == s.value"
>
{{'Force no backup' | translate}}
</option>
<option value="UseAPIParameter" ng-selected="'UseAPIParameter' == s.value">
{{'UseAPIParameter' | translate}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add translation keys for these values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the translation in en-admin.json. Please check

Copy link
Copy Markdown
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

Tested and works fine, once updated the translations looks fine to be merged.

@wangf1122 wangf1122 requested a review from josegar74 May 12, 2025 13:27
@ianwallen ianwallen merged commit 2cf79d8 into geonetwork:main May 12, 2025
7 checks passed
@geonetworkbuild
Copy link
Copy Markdown
Collaborator

The backport to 4.2.x failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 4ed8e7d4df... setting option to enable/disable backup during delete record
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

stdout
Auto-merging web-ui/src/main/resources/catalog/components/catalog/CatalogService.js
Auto-merging web-ui/src/main/resources/catalog/locales/en-admin.json
CONFLICT (modify/delete): web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v447/migrate-default.sql deleted in HEAD and modified in 4ed8e7d4df (setting option to enable/disable backup during delete record).  Version 4ed8e7d4df (setting option to enable/disable backup during delete record) of web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v447/migrate-default.sql left in tree.

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.2.x 4.2.x
# Navigate to the new working tree
cd .worktrees/backport-4.2.x
# Create a new branch
git switch --create backport-8728-to-4.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 4ed8e7d4dfcf04d487dc47e9b84f6e8d420d6c59,17b4ed4402239105b8797daa7f277aeb59517e83,71bb392c41fbee52b30fb2ce6ac399aeb8a89efc,1077817a8ce60f13f6e3887fa78f31435e9d23ad,d1d7ab1a95d9cd4c493f14da3daec00a5448a417,2419f219552eeb2e41f5e905b46028fa0b569b94
# Push it to GitHub
git push --set-upstream origin backport-8728-to-4.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.2.x

Then, create a pull request where the base branch is 4.2.x and the compare/head branch is backport-8728-to-4.2.x.

ianwallen pushed a commit to ianwallen/core-geonetwork that referenced this pull request May 12, 2025
…e record (geonetwork#8728)

* setting option to enable/disable backup during delete record

* Change default of withBackup to allow null and default with setting value.

* System setting of delete record backup options

* Change no preference to Use API parameter option

* update translation
ianwallen added a commit that referenced this pull request May 12, 2025
…e record (#8728) (#8784)

* setting option to enable/disable backup during delete record

* Change default of withBackup to allow null and default with setting value.

* System setting of delete record backup options

* Change no preference to Use API parameter option

* update translation

Co-authored-by: wangf1122 <74916635+wangf1122@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants