Workspace can't be opened when a stopped change's article is replaced by a link, folder or FIFO

Open
#76 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reading Workspace.load and the recovery logic for .text-fetch/publishing-article.json, then trace the add_file replacement and removal paths described in the reproduction. Reproduce the stopped-process cases with a symlink, folder, FIFO, and broken link, and inspect how recovery handles staged versus published versions. The issue needs a decision on recovery behavior; done means the chosen behavior lets a workspace reopen and reports any lost article data clearly.

Written by the indexing model from the issue text.

Description

area:workspace bug impact:crash

A workspace records each article change in .text-fetch/publishing-article.json and finishes it on the next write or open. Suppose the process stops partway through a change, and before the next open the article path named in that record is replaced by something that isn't an article. Every later open then raises WorkspaceError until someone deletes the record by hand.

This affects moves between valid/ and incomplete/, replacements in the same folder, and removals. It was found while reviewing the fix for #72. Main (d4e507e) behaves the same, and the #72 fix doesn't change it.

Repro

  1. Create a workspace with a PDF article saved as valid: add_file("<old/>", "10.1/scan", "pdf", "s", True, "scan.jats.xml", pdf_sha1="abc").
  2. In a child process, call add_file("<new/>", "10.1/new", "pdf", "s", False, "scan.jats.xml", pdf_sha1="abc"). Patch os.replace so the process exits right after the rename onto publishing-article.json, or after the rename that publishes incomplete/scan.jats.xml.
  3. Replace incomplete/scan.jats.xml as in the table below.
  4. Call Workspace.load.
Stopped after incomplete/scan.jats.xml replaced by Every open
the record was written (new version staged) a symbolic link out of the folder WorkspaceError: Article path leaves the workspace
the new version was published a folder, a FIFO or a broken link WorkspaceError: Cannot recover missing workspace article
the new version was published a symbolic link out of the folder WorkspaceError: Article path leaves the workspace

The same happens when the replacement is a link, folder or FIFO at the target of a same-folder replacement or of a removal.

Why this needs a decision

  • Before publication the change can still be undone: discard the staged version and drop the record. The old article is untouched.
  • After publication the new version is gone, so the record can't be finished. It can't be cleanly undone either: the record holds the new DOI records, not the old ones, and the old copy may already be deleted.

Options:

  1. Undo while the staged version exists. After publication, drop the record and rebuild the affected index entries and counts from the files on disk, reporting the DOIs that no longer have an article.
  2. Keep the error, but make it name the record to delete and say what deleting it loses.
  3. Leave it. Someone has to replace an article file between a stop and the next open.
Dominant language
Python
Stars
1
Forks
0
Avg merge
1h 1m
Merged PRs (30d)
31

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/text-fetch

All issues in lanl/text-fetch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.