Problem/Motivation

Views cached table information can become corrupted with entries which lead Views to skip configured filters. This results in rendering views with inaccurate output, specifically showing incorrect data where correct behaviour would filter it out (#2907954: Views with broken handlers still return results even if the results might be incorrect).

Reporting this as a separate bug to #2907954: Views with broken handlers still return results even if the results might be incorrect as that issue is relates to showing results incorrectly, while this is about corruption of the Views table information cache.

Cache data in drush cache:get views_data:node__field_foo:en below is similar to #3569624: ViewsData::getData() Fiber race condition causes empty cache entries / #3565020: Set the Drupal\views\ViewsData::$fullyLoaded property to TRUE only when the data is really loaded.. However, this was observed running on Drupal version (11.3.22) which includes those fixes. Memcache pod is cycled on each deployment.

Analysis

Inspection through the UI found that a field, sort and filter were showing as "Broken/missing" in the Views UI. Other fields, sorts and filters using the same plugin id as the broken/missing instances were displaying fine. In all cases, the

Inspected the `views_data:en` cache item and found that all expected information was present - the data looked complete but we found the timestamp was much newer that when the issue was first reported. E.g. the issue was present, but the `views_data:en` cache has been set after and so did not reflect what was cached at the time the issue was reported to us.

Further debugging found that it was the per table cache was set as an empty array - and the timestamp on these appeared consistent with when the issue started appearing.

E.g

$ drush cache:get views_data:node__field_foo:en
{
    "cid": "views_data:node__field_foo:en",
    "data": [],
    "created": 1795885595.312,
    "expire": -1,
    "tags": [
        "config:core.extension",
        "memcache:default",
        "views_data"
    ],
    "checksum": 0,
    "valid": true
}

Looking at the ViewsData code and given the presence of the expected cache tags I believe this would have been set here https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/views...

This leads me to believe either `getData` returns nothing, or it returned _partially_ complete data.

When the table caches were evicted from memcache and rebuilt - either the views_data cache existed and was bad, or was built as part of the call to getData and was bad - and an empty array was cached.

Steps to reproduce

No clear steps to reproduce yet. We can identify the situation by the presence of empty array data in Views data cache. We observed this with Drupal 11.3 / PHP 8.3 / Memcached.

The view in question has 6 blocks embedded on the same page - if there is some additional race condition with Fibers, could having several displays be a factor?

The same output can be manually manipulated to see a view render without its configured filters.

  1. Configure a view with a filter (e.g. field_foo)
  2. Load the view to ensure the views and table caches exist.
  3. Manipulate views data cache manually (unclear how this happens in the wild): drush ev "\Drupal::cache()->set('views_data:en', [], \Drupal\Core\Cache\Cache\Cache::PERMANENT, ['views_data', 'config:core.extension']);"
  4. Delete the cache for the field table used in the filter drush ev "\Drupal::cache()->delete('views_data:node__field_foo:en');"
  5. Reload the viewed

View renders on the page with no error, and shows data without the filter on `field_foo` applied.

Proposed resolution

Root cause not yet established, no proposed solution yet.

Comments

ericgsmith created an issue. See original summary.

xurizaemon’s picture

Issue summary: View changes
xurizaemon’s picture

Issue summary: View changes