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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Issue summary: View changes

more precise description

yched’s picture

Issue summary: View changes

typo

yched’s picture

Status: Active » Needs review
FileSize
2.4 KB
1.1 KB

Patch + test-only patch.

yched’s picture

Issue summary: View changes

more specific

xjm’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

This looks good to me.

xjm’s picture

Issue summary: View changes

typo

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Makes sense. Committed/pushed to 8.x.

oriol_e9g’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.35 KB
xjm’s picture

Status: Needs review » Reviewed & tested by the community

Backport is fine as well.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oops. :) Thanks for the fix, and the test!

Committed and pushed to 7.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

rephrase