[BE] Move the competency authoring mutex off the shared Tag row onto a CBE-owned lock row
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the four criteria writers that call Tag.objects.select_for_update() (associate_competency_criterion, create_competency_criterion, bulk_update_competency_criteria, update_competency_criteria_group, delete_or_archive_competency_criterion) and the CompetencyCourseRun model as the pattern to copy. Read test_criterion_concurrency.py and the run_when_tag_lock_is_taken fixture in the CBE test conftest, since the SQLite lock-point tests pin the old call and must be rewritten. Done when all writers lock the new per-competency row, the MySQL two-connection tests pass, and ADR-0004's Decision 6 note is updated.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
User Story
As an Open edX operator, I want competency authoring requests to serialize on a row the CBE app owns, in order to keep other parts of the platform from waiting on a lock they know nothing about.
Description
The four competency criteria writers (create criterion, bulk update criteria, update group, delete criterion) serialize per competency by taking a select_for_update() lock on the competency's Tag row in openedx_tagging. We need the same serialization on a CBE-owned per-competency row instead, so that inserts referencing the Tag row elsewhere in the platform stop waiting on authoring transactions.
Low priority: the Tag lock is accepted for MVP, and the cost is small (waiters hold for one authoring transaction, and the known deadlock cycles fail one request loudly with no corruption).
Context
- The Tag lock and the one-lock writer rule landed with https://github.com/openedx/openedx-core/pull/879 (https://github.com/openedx/openedx-core/issues/674); that PR's review accepted the Tag row for MVP and asked for this follow-up.
- https://github.com/openedx/openedx-core/pull/847 first added the Tag lock, and the maintainer asked there not to rely on locking the Tag long term. Its earlier follow-up, https://github.com/openedx/openedx-core/issues/872, replaced the lock's one-root guarantee with a database constraint (https://github.com/openedx/openedx-core/pull/900) but kept the lock for the duplicate-criterion check, which no constraint can express.
CompetencyCourseRunis the repo's precedent for this pattern: CBE locks its own row rather than the catalog'sCourseRun, so other apps' writes don't block.- While an authoring request holds the Tag lock, every insert referencing that
Tagrow waits on InnoDB's foreign-key shared lock: object tags from ordinary Studio tagging, child tags from a taxonomy import, andStudentCompetencyStatusrows.
Acceptance Criteria
Scenario: authoring requests for one competency still run one at a time
Given two concurrent authoring requests for the same competency, one deleting a criterion and one bulk-updating it
When both run to completion
Then one waits for the other and neither fails with a deadlock error
Scenario: tagging content with a competency no longer waits for an authoring request
Given an authoring request for a competency is holding its per-competency lock
When another request tags unrelated content with that competency through the tagging API
Then the tagging request completes without waiting for the authoring request to commit
Scenario: authoring requests for different competencies do not serialize on each other
Given two concurrent authoring requests for two different competencies
When both run
Then neither waits on the other's lock
Technical Details
Technical Details
This is a suggested approach, not the source of truth. The User Story, Description, and Acceptance Criteria define what must be true when the work is done.
Summary
Add a CBE-owned per-competency lock row, created with get_or_create() and locked with select_for_update(), and point all four writers at it instead of the Tag row, following the CompetencyCourseRun pattern.
Approach
- A small model (for example
CompetencyLock, a OneToOne on the competency'sTag) whose only job is to be the lock target;get_or_create()before the locking read, since a locking read of a row that doesn't exist locks nothing. - Replace the
Tag.objects.select_for_update()reads inassociate_competency_criterion,create_competency_criterion,bulk_update_competency_criteria,update_competency_criteria_group, anddelete_or_archive_competency_criterion. - The two-connection MySQL tests in
test_criterion_concurrency.pyassert outcomes, so they must stay green and survive the move (the lock-probe test asserts the lock target and changes with the model). The SQLite lock-point tests built on therun_when_tag_lock_is_takenfixture in the CBE test conftest pinTag.objects.select_for_updateas the call being made, so they all need rewriting against the new lock target; the reviewer on https://github.com/openedx/openedx-core/pull/879 flagged exactly this and advised leaning on the MySQL outcome tests rather than adding more call-site pins. - ADR-0004's Decision 6 note on the authoring writers moves to the new row.
- Lingua principale
- Python
- Stelle
- 10
- Fork
- 35
- Merge medio
- 5g 2h
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openedx/openedx-core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
openedx/openedx-core#934 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openedx/openedx-core#922 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
openedx/openedx-core#831 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
openedx/openedx-core#827 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Competency Criteria Associations: any/all differs from the design, inline score error breaks the layout on narrow screensForse già presa @illiphilli l’ha presa oggi. Aperta
openedx/openedx-core#938 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openedx/openedx-core
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
btclib-org/btclib-wallet#1045 ·
I maintainer di solito rispondono entro 1 giorno
-
area-templates triage:bot-seen triage:needs-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/aspire#22356 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Train] An elastic ScalingConfig(num_workers=(0, 0)) is accepted and the run waits foreverForse già presa @wguo7 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
ray-project/ray#68217 ·
I maintainer di solito rispondono entro 2 giorni