-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Fix issue with saving metadata status causes indexing of metadata which causes issues for db rollbacks #7514
Fix issue with saving metadata status causes indexing of metadata which causes issues for db rollbacks #7514
Conversation
So the issue is that the application is calling the function to set the status. There are a few ways to fix this. The following comments indicates that the set status is not supposed to update the index? Not sure if this comment should be updated? core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataStatus.java Line 149 in e75ee33
One option could be to change the call to so that instead of It would instead call the following instead? Maybe others have some input on this issue? |
I think that comment means that the database is updated and the metadata reindexed, as it's implemented. About your change looks ok (need to test it), but I would be good to document in which cases should be pass a Something to explore would be to check if indexing can be done in the transaction manager after commit, but I'm afraid that will require some major refactoring to store the list of metadata to reindex and verify that it doesn't affect other functionality. |
There is no javadocs for the function being modified So I think the comment means that it is expected that you will need to later re-index after the function is called. It is odd to have an override version which does do indexing? It seems inconsistent to me. If all the process which depend on setStatusExt function would handle re-indexing then this issue may not have occurred? |
@ianwallen in the interface, both definitions for core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/IMetadataStatus.java Lines 63 to 76 in e75ee33
This implementation looks wrong according to the previous documentation: core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataStatus.java Lines 163 to 167 in e75ee33
If you compare with this other implementation that doesn't reindex as indicated in the interface: core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataStatus.java Lines 175 to 195 in e75ee33
I'm fine with the change, but please update the interface documentation also. |
@@ -221,7 +221,7 @@ public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOf | |||
private boolean applyStatusChange(int metadataId, MetadataStatus status, String toStatusId) throws Exception { | |||
boolean deleted = false; | |||
if (!deleted) { | |||
metadataStatusManager.setStatusExt(status); | |||
metadataStatusManager.setStatusExt(status, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applyStatusChange
is used in StatusActions.onStatusChage
that is call when creating a draft version:
core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/draft/DraftMetadataUtils.java
Line 592 in 1f16287
sa.onStatusChange(listOfStatusChange); |
Previously was indexed the metadata and with this change no. Have you check that creating a draft contains the proper status in the index? Otherwise DraftMetadataUtils.createDraft
needs to explicit index the draft metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the java doc for sure. As for the logic, sure I can do that "not updating the index". But you see the issue of the original code is it does opposite. It forces to update the index instead of "not update". So if you are sure, the flag i place here as false is good, then i will go with the change. Edited: Sorry, I missed some of your comment. Looks like the original implementation is wrong as you said. I will update the flag as well |
@wangf1122 yes, the original code of forces to update: core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataStatus.java Lines 163 to 167 in e75ee33
Contrary to what the doc indicates and the other core-geonetwork/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataStatus.java Lines 175 to 195 in e75ee33
With the change you've done, I think #7514 (comment) not index the metadata, while with the previous implementation was indexed, no? |
094c1b4
to
71368be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the changes with the workflow enabled, but submitting a metadata for revision doesn't change the status from draft
to submitted
, the popup displays that the status has been changed successfully, but it doesn't. Please review it.
@josegar74 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, looks fine.
The backport to
stderr
stdout
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-3.12.x 3.12.x
# Navigate to the new working tree
cd .worktrees/backport-3.12.x
# Create a new branch
git switch --create backport-7514-to-3.12.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 01a7f2f623c71b8ae6b6c3112239e460214fb75d,8a49652c30471a7cde6de41565eb66c8c4174daf,71368be4855748e2cc2bfb3264c0a9fdfd92e218,d4a4255f1045c7f0b872a4408d606a1342b06fd2
# Push it to GitHub
git push --set-upstream origin backport-7514-to-3.12.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-3.12.x Then, create a pull request where the |
The issue happens in this API where the index was update prematurely.
It's supposed to be done here
core-geonetwork/services/src/main/java/org/fao/geonet/api/records/MetadataWorkflowApi.java
Line 508 in e75ee33
But was updated within this code above the thread
core-geonetwork/services/src/main/java/org/fao/geonet/api/records/MetadataWorkflowApi.java
Line 502 in e75ee33
We should add such option to prevent the index updated.
The issue is if something happens in the publish event into the customized event listener. There are exceptions can be thrown due to the business logic check
core-geonetwork/core/src/main/java/org/fao/geonet/kernel/metadata/DefaultStatusActions.java
Lines 203 to 206 in e75ee33
The database will roll back properly. But the search engine will have the updated status. If we refresh the web page, it will display the wrong status.
For example,
Retired failed due to some business logic check in event listener.
Here is the search engine's result
http://localhost:8080/catalogue/srv/eng/q?_content_type=json&_draft=y+or+n+or+e&_isTemplate=y+or+n&fast=index&uuid=476399f3-ec21-4792-9a7b-8b36800946dc