Found out when working on the field info cache optimization in #1040790: _field_info_collate_fields() memory usage :
When a vocab machine name gets changed, there can be a race condition where entity_get_info() stores stale data and still lists the old bundle instead of the new one :
- taxonomy_entity_info() relies on taxonomy_vocabulary_get_names() to fetch the list of 'taxo terms' bundles (= vocabs).
That function queries the {taxonomy_vocabulary} table and caches the results in a static var.
- when creating / updating a vocab, taxonomy_vocabulary_save()
writes to {taxonomy_vocabulary},
calls field_attach_[create|rename]_bundle(), which clears the entity_info() cache
then calls a couple hooks (hook_entity_[insert|update]...),
and only then clears the taxonomy_vocabulary_get_names() static cache.
--> If anything calls entity_get_info() in between (and field_sql_storage_field_attach_rename_bundle() does, through field_read_instances()), then entity_get_info() gets rebuilt based on the stale static list of vocabs, and primes its own static + persistent caches with it.
Patch coming up.
Comment | File | Size | Author |
---|---|---|---|
#4 | taxonomy-static-1391384-4.patch | 2.35 KB | oriol_e9g |
#1 | taxonomy_static_cache-1391384-test-only.patch | 1.1 KB | yched |
#1 | taxonomy_static_cache-1391384.patch | 2.4 KB | yched |
Comments
Comment #0.0
yched CreditAttribution: yched commentedmore precise description
Comment #0.1
yched CreditAttribution: yched commentedtypo
Comment #1
yched CreditAttribution: yched commentedPatch + test-only patch.
Comment #1.0
yched CreditAttribution: yched commentedmore specific
Comment #2
xjmThis looks good to me.
Comment #2.0
xjmtypo
Comment #3
catchMakes sense. Committed/pushed to 8.x.
Comment #4
oriol_e9gComment #5
xjmBackport is fine as well.
Comment #6
webchickOops. :) Thanks for the fix, and the test!
Committed and pushed to 7.x. Thanks!
Comment #7.0
(not verified) CreditAttribution: commentedrephrase