Allow publishing conditional on indexing being done, add /timestamps#7640
Merged
kcondon merged 4 commits intoIQSS:developfrom Mar 8, 2021
Merged
Conversation
landreev
approved these changes
Mar 5, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it: This PR is one way of handling the issue where publishing can fail do to OptimisticLockExceptions. This implementation adds an optional boolean query parameter to the publish API call - assureIsIndexed - that, if true, causes the call to return a 409/conflict error if indexing is pending (determined by checking both the modification/permissionmodification times against the respective indextime/permissionindextimes). Without the parameter, there are no changes to how things work.
The PR also adds a /timestamps endpoint that reports various timestamps (a subset on the latest published version only, and, if you have permission to view the draft, the complete set of timestamps for the latest/draft version). The endpoint also includes two booleans indicating whether the index /permission index is stale (earlier than the corresponding modification times). The intent with the endpoint and these booleans in particular is to make it easy to wait for indexing to finish if other calls that modify the dataset are found to have the same issue. (Nominally one could add the same query param on those methods, but this would enable a polling-based workaround without waiting for further software updates.
Which issue(s) this PR closes:
Closes #7637
Special notes for your reviewer: I think this approach is valuable for DANS/others doing automated upload/edit/publishing. Something is needed asap. That said, I'd hope that other design changes could eventually remove the need for this, i.e. if indexing did not change the Dataset/interfere with its modification by calls setting locks.
Also note that the extra logic checking for permissionmodificationtime being null is due to #7625.
Suggestions on how to test this: Should test that things work as is now with the publish api. To test the new param, the easiest approach might be to set it to true and set the index time for the dataset to null before calling publish (should result in 409/conflict). Re-indexing or setting the index time later than the modification time would then allow publish to succeed. (Alternately, one could try to create a dataset with slow indexing and call edit and then publish quickly enough to see a 409. This is essentially what DANS is doing.)
Does this PR introduce a user interface change? If mockups are available, please link/include them here: no
Is there a release notes update needed for this change?:
Additional documentation: will add docs of the new param and new /timestamps call if/when the code is approved.