Skip to content

Proper handling of exceptions when exporting metadata#8782

Merged
kcondon merged 4 commits intodevelopfrom
8484-failing-export-detection
Jul 22, 2022
Merged

Proper handling of exceptions when exporting metadata#8782
kcondon merged 4 commits intodevelopfrom
8484-failing-export-detection

Conversation

@landreev
Copy link
Contributor

@landreev landreev commented Jun 8, 2022

What this PR does / why we need it:

This is a simple PR that fixes exception handling during metadata exports, making sure the "last exported" time stamp does not get updated unless it was successful.

Which issue(s) this PR closes:

Closes #8484

Special notes for your reviewer:

Suggestions on how to test this:

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Additional documentation:

ExportService instance = ExportService.getInstance();
instance.exportAllFormats(dataset);

ctxt.datasets().updateLastExportTimeStamp(dataset.getId());
Copy link
Member

Choose a reason for hiding this comment

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

Why both this and setting the update time in exportAllFormats?

Could/should it just be removed here? (Or is a ctxt.datasets().merge(dataset); or similar needed to get the update from the ExportService? )

Can you even get rid of updateLastExportTimeStamp? (I see it called three places, all after a call to exportAllFormats (andexportAllFormats is called a few more places where updateLastExportTimeStamp isn't called)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit stumped by this actually... With the line 264 above commented out the time stamp does not get updated. And I can't immediately tell why. Is there still something finicky about the transaction under which onSuccess() is called, in this context, of FinalizeDatasetPublicationCommand being executed as a "nested" command?
Not sure about .merge(dataset), why it would be needed - as opposed to having all the changes done to the dataset getting saved automatically at the end of the transaction. ExportService is not an EJB itself, despite the name.
OK, I would need to experiment some more to figure this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhm, I would like to just declare this out of scope - figuring out why that line is necessary. It has been there for a while.

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest at least a comment since you found it isn't doing anything / doesn't appear to anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"isn't doing anything"?
Oh, you mean, not the line highlighted above, but the .setLastExportTime() line inside the ExportService.exportAllFormats() method (?).
Sure, I can add a comment here saying that "exportAllFormats() tries to set the last export timestamp; but for some reason that modification isn't getting saved when exportAll is called from here (transaction?), hence this explicit .updateLastExportTimeStamp() is necessary".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, an explicit .merge() call there makes calling that method unnecessary.
Guessing it may be possible to get rid of it in the other 2 places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok.

@kcondon kcondon self-assigned this Jul 11, 2022
@kcondon kcondon merged commit b9e207e into develop Jul 22, 2022
@kcondon kcondon deleted the 8484-failing-export-detection branch July 22, 2022 14:46
@kcondon kcondon self-assigned this Jul 25, 2022
@pdurbin pdurbin added this to the 5.12 milestone Jul 25, 2022
pdurbin added a commit to pdurbin/dataverse that referenced this pull request Sep 8, 2022
…atches IQSS#8720

Conflicts:
src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java

It looks like @landreev removed the updateLastExportTimeStamp method
in 8135490 as part of PR IQSS#8782 so I made sure it's still gone.
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.

Failure to export dataset not detected, dataset marked as exported

5 participants