Deleting a tag or taxonomy emits search-index events for objects tagged in other taxonomies
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
Línea de trabajo
Empieza con tag_pre_delete en src/openedx_tagging/signal_handlers.py y compara su consulta con las consultas de linaje limitadas por taxonomía mencionadas en api.py y models/base.py. Añade una prueba de regresión en tests/openedx_tagging/test_models.py que use dos taxonomías con el mismo valor de etiqueta raíz. Se considera terminado cuando eliminar la taxonomía no utilizada no emite ningún evento para el objeto etiquetado únicamente en la otra taxonomía, mientras que el comportamiento de eliminación existente sigue estando cubierto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
When a tag is deleted, tag_pre_delete in src/openedx_tagging/signal_handlers.py collects the objects whose search documents need refreshing with ObjectTag.objects.filter(tag__lineage__startswith=instance.lineage). A tag's lineage is the tab-separated chain of tag values from the root to the tag, and it carries no taxonomy. The filter therefore matches every object tagged with a tag of the same value path in any taxonomy, not just the taxonomy being changed. Deleting a whole taxonomy runs the same filter for each of its root tags.
The handler was added in https://github.com/openedx/openedx-core/pull/571 for https://github.com/openedx/modular-learning/issues/260, and https://github.com/openedx/openedx-core/pull/575 extended it to taxonomy deletes. The unscoped filter is on main and in the 1.0.x releases.
The cross-taxonomy match does not look intended. The description of https://github.com/openedx/openedx-core/pull/571 speaks of "a tag and its descendants", and the code comments say the root tag's handler "covers the whole subtree". The event spec in https://github.com/openedx/openedx-core/issues/557 asks for events for "every object tagged using that particular tag" on a tag delete and "every object that had been tagged using that taxonomy" on a taxonomy delete. The tests in tests/openedx_tagging/test_models.py use a single taxonomy, so none of them covers the case. Neither PR's review discussed matching across taxonomies.
Steps to reproduce
- In Studio, create taxonomy A with a root tag
Math, make it available to an organization, and applyMathto a library component or a course unit of that organization. - Create taxonomy B with a root tag
Math. Don't apply it to anything. - Delete taxonomy B.
- Check the CMS log.
Expected result
Taxonomy B has no object tags, so deleting it emits no CONTENT_OBJECT_ASSOCIATIONS_CHANGED events and logs nothing about associated objects.
Actual result
Following the handler code, CMS logs Deleted tag(s) affected 1 associated objects. Emitted CONTENT_OBJECT_ASSOCIATIONS_CHANGED events. The object tagged in taxonomy A gets an event and its search document is rebuilt, although none of its tags changed. The same happens when only the tag Math is deleted from taxonomy B rather than the whole taxonomy.
The search data stays correct, because the platform handler rebuilds the document from the object's current tags. The cost is extra work: one event and one index update per matching object, for every delete.
Measured on a local Tutor dev stack (openedx-core 7e150e7), where Celery runs eagerly so the events are emitted inside the request: deleting a taxonomy with no object tags of its own, whose root tag value matched 60 objects tagged in other taxonomies, returned 204 after 18.8 s. After those 60 object tags were removed, the same delete took 0.15 s. On an install with Celery workers the request itself stays fast, and the extra events go to the workers instead.
Impact
Tag values like Math, Beginner or Python are common across taxonomies, and taxonomies are often created by copying or re-importing an existing one. On such an install, deleting one tag or one unused taxonomy queues index updates for every object tagged with the same value in any other taxonomy, potentially thousands. Installs without Celery workers, such as development stacks, can hit request timeouts.
Suggested fix
Scope the query to the tag's own taxonomy:
ObjectTag.objects.using(using)
.filter(tag__taxonomy_id=instance.taxonomy_id, tag__lineage__startswith=instance.lineage)
The other lineage__startswith queries in openedx_tagging already scope to the taxonomy (api.py, and Tag.descendant_count and Tag.save in models/base.py), so this one is the only exception. A regression test can create two taxonomies with the same root tag value, tag an object in the first, delete the second, and assert that no event is emitted.
- Lenguaje dominante
- Python
- Estrellas
- 10
- Forks
- 35
- Merge medio
- 5 d 2 h
- PR fusionados (30 d)
- 23
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openedx/openedx-core
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openedx/openedx-core#922 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
openedx/openedx-core#831 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
openedx/openedx-core#827 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Competency Criteria Associations: any/all differs from the design, inline score error breaks the layout on narrow screensPosiblemente ocupada @illiphilli la tomó hoy. Abierto
openedx/openedx-core#938 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
openedx/openedx-core#935 ·
Los mantenedores suelen responder en 1 día
Todos los issues de openedx/openedx-core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
can4hou6joeng4/boss-agent-cli#1487 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
btclib-org/btclib-wallet#1045 ·
Los mantenedores suelen responder en 1 día
-
area-templates triage:bot-seen triage:needs-human
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/aspire#22356 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100