🇨🇳China @weynhamz

Ningbo
Account created on 10 November 2008, about 16 years ago
  • Architecture Manager at CI&T 
#

Recent comments

🇨🇳China weynhamz Ningbo

A peculiar issue arose during one of our projects that was exclusive to the Acquia cloud. After monitoring and debugging for weeks, we finally identified the root cause of the problem which led us to this issue.

Our homepage, which uses the Layout Builder, would randomly lose its entire content section without any errors in the logs. There was no discernible pattern of its occurrence. However, we were able to confirm that a corrupted module_implements cache was the culprit. We eventually connected the dots and identified the problem.

Since our website was on Acquia, Memcache was configured and enabled by default. It was also used for cache bins such as `bootstrap`, `discovery`, and `config`. The `entity_type` cache item is located within the `discovery` bin. For a production server shared with multiple sites, Memcache evicts items. Our problem occurred when the `entity_type` cache item was evicted, and we had the key module configured with the Shield.

To reproduce this issue, simply ensure that Shield is configured with the Key module, and then execute the following command with drush:

```
drush ev '\Drupal::cache("discovery")->delete("entity_type");'
```

Upon the next refresh, the `module_implements` cache will become corrupted. We temporarily fixed by adding the following lines at the beginning of the `handle()` method of the `ShieldMiddleware`.

```
// @see https://www.drupal.org/project/shield/issues/3277210 🐛 Shield middleware invokes hooks before modules are loaded, corrupting module_implements cache Needs work
// Prevent corrupting the module_implements cache.
$this->moduleHandler->loadAll();
```

Although this could be better resolved by invoking the low-level API of the Key module.

Production build 0.71.5 2024