IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
879 stars 486 forks source link

Publish Dataset locks forever if working with a dataset in two tabs at the same time #10120

Open beepsoft opened 10 months ago

beepsoft commented 10 months ago

What steps does it take to reproduce the issue?

  1. Create a dataset in one tab (Tab1)
  2. Open the same dataset in another tab (Tab2)
  3. In Tab1 add a "Subtitle" value via Metadata > Add + Edit Metadata > Add a subtitle and Save changes
  4. Switch to Tab2 and press "Publish Dataset"

Publishing will fail with this error:

Error – Command edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetCommand@ae7d829 failed: Exception [EclipseLink-5010] (Eclipse Persistence Services - 4.0.1.payara-p1.v202304041433): org.eclipse.persistence.exceptions.OptimisticLockException Exception Description: The object [[DatasetVersion id:9]] cannot be merged because it has changed or been deleted since it was last read. Class> edu.harvard.iq.dataverse.DatasetVersion If you believe this is an error, please contact Root Support for assistance.

And the

Publish in Progress – The dataset is locked while the persistent identifiers are being registered or updated, and/or the physical files are being validated.

message will be displayed indefinitely because the dataset will remain in a locked state forever because of the previous error

When working with the same dataset in multiple browser tabs and doing editing in one tab and pubishing in another one.

Any user.

Publishing should not fail no matter how many tabs the dataset is edited in.

Which version of Dataverse are you using?

6.0

Screenshots:

Screenshot 2023-11-14 at 15 01 55

Possible solution

The cause of the problem seems to be that the UI state is stored in a DataversePage object and it has an instance of the Dataset, which have already changed in the database:

https://github.com/IQSS/dataverse/blob/3305c4a41045d0bb2f261c5eb2aa93414a34f2c6/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java#L2753-L2759

Here at line 2756 doing something like this before submitting the PublishDatasetCommandwould resolve this issue:

                dataset = datasetService.find(dataset.getId());
                final PublishDatasetResult result = commandEngine.submit(
                    new PublishDatasetCommand(dataset, dvRequestService.getDataverseRequest(), minor)
                );
qqmyers commented 10 months ago

FWIW: I'd say this is more 'as designed'. If you (or someone else) can edit a data in one window, and you can publish in another, you'd potentially be publishing something you haven't seen. It would probably help to have a better error message, i.e. the dataset may have changed since you've viewed it, please refresh the page before publishing. (Note I say may have because some changes to a dataset are things like it now being indexed which wouldn't be a change to dataset as seen by the user.)

beepsoft commented 10 months ago

A message to the user forcing to reload the page seems a good solution to me. (In case of the new SPA UI it maybe a good idea to have a websocket like mechanism as well to get notifications of such changes.)

The underlying data may change via API calls or by some other processes (in our case because of our RO-Crate editor's update of a dataset's data), so it is definitely necessary to notify the user that what they see on screen are out of sync with the underlying data.