Skip to content

fix(store): retry the section tree rebuild after a deadlock - #73

Merged
Rl0007 merged 1 commit into
mainfrom
fix/parse-deadlock
Oct 6, 2026
Merged

Rl0007 merged 1 commit into
mainfrom
fix/parse-deadlock

Conversation

@Rl0007

@Rl0007 Rl0007 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
  1. When several PDFs were imported at once, one of them could end as Failed at "Building section tree", with a misleading "SAVEPOINT does not exist" error.
  2. Parallel imports now all reach Review: a database deadlock while building the section tree is retried instead of failing the import.

You can visit Documents and upload several PDFs at once to see it.

Fixes #32

Verification
  • Approach: retry the whole tree rebuild (up to 3 attempts, short random wait) after a full rollback, using tenacity as frappe's job runner does. A lock was not used: the tree rows stay locked until the job commits, so a lock released at the end of the rebuild would not stop the deadlock.
  • New test TestReplaceSectionsAfterDeadlock in test_section_surgery.py makes one insert raise QueryDeadlockError after a real rollback. It fails on main with 1305 "SAVEPOINT does not exist" and passes here with the correct tree.
  • Full suite on the devbox: 486 ran, 475 pass, 11 skip, 0 fail (baseline 474 + the new test).
  • Devbox e2e, 3 workers on the long queue, 8 imports started at once: main 7/8 Review (1 Failed on 1305). This branch 16/16 Review over two rounds, with a real InnoDB deadlock on tabSource Section logged during the second round and retried.
  • Reviewer: approved. No LLM calls were involved (the box has no model key).

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@Rl0007
Rl0007 merged commit 4ad7c09 into main Oct 6, 2026
3 checks passed
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.

An import can fail when many PDFs are uploaded at once

1 participant