Possible regression during serialization after 9.3.22 (9.4.0 to 9.4.8)

Created on 5 November 2022, almost 2 years ago
Updated 14 July 2023, about 1 year ago

Problem/Motivation

After updating to Drupal 9.4.7 from 9.3.5, we are encountering segmentation violations (ProcessSignaledException) when running Search API to index items. From Drupal 8 to 9.3.5, these lines of code have never had an issue until now.

We have a custom token on the site:

case 'author_list_raw':
          $node = $data['node'];

          $authors = [];
          $context = ($node->getType() == 'working_paper' || $node->getType() == 'chapter') ? 'paper_author_list' : 'author_list';
          $author_items = \Drupal::service('serializer')->normalize($node, 'array', [$context => TRUE]);

          if (isset($author_items['authors'])) {
            foreach ($author_items['authors'] as $author) {
              $authors[] = $author['name'];
            }
          }

          $replacements[$original] = !empty($authors) ? implode(', ', $authors) : NULL;

          break;

The serializer returns an array of data - it digs through paragraphs to get the strings we want to output with the token, returned from a custom Normalizer. This, and the Normalizer, have remain unchanged for over a year.

This token is used in one of the Metatag fields on nodes. The serializer is also used during the indexing process to add additional data to a document, similar to what the token is doing above.

Prior to 9.4.7, this worked without fail and we could index all 100,000 items on the site with no issue.

After updating to 9.4.7, Drush will exit (and so will the Search API UI in the admin) with a segmentation fault:

drush sapi-i myindex --limit=10

In Process.php line 441:
                                                   
  The process has been signaled with signal "11".  

Every single time, it is breaking on the call to the serializer. The call will be hit, wait about 10 seconds, then die with the message above.

I went back and tried 9.3.6 and up through 9.3.22 where this works just fine. The items that were causing this error were indexed fine. Once I go to 9.4.0 and any version up to 9.4.8, the issue re-appears. I have tried this several times.

I can't figure out if this is a change in core, one of the Symfony dependencies or something else. I updated Metatag and Search API / Search API Solr to their latest versions and the problem persists, so I am not sure where to look to narrow down what is going on.

I did find that in ContentEntityNormalizer, if I change the code to exclude anything called 'metatag', the process runs fine with no error:

/**
 * Normalizes/denormalizes Drupal content entities into an array structure.
 */
class ContentEntityNormalizer extends EntityNormalizer {

  /**
   * {@inheritdoc}
   */
  protected $supportedInterfaceOrClass = ContentEntityInterface::class;

  /**
   * {@inheritdoc}
   */
  public function normalize($entity, $format = NULL, array $context = []) {
    $context += [
      'account' => NULL,
    ];

    $attributes = [];
    /** @var \Drupal\Core\Entity\Entity $entity */
    foreach (TypedDataInternalPropertiesHelper::getNonInternalProperties($entity->getTypedData()) as $name => $field_items) {
      if ($field_items->access('view', $context['account']) && $name != 'metatag') {
        $attributes[$name] = $this->serializer->normalize($field_items, $format, $context);
      }
    }

    return $attributes;
  }

}

Although this just masks the issue - at this point I don't know what to look through, but the only change in the last few weeks that was made was updating from 9.3.5 to 9.4.7. Hoping someone may be aware and able to point out the change or issue here, I am stumped.

Tried both latest versions of PHP 7.4 and 8.0.

πŸ’¬ Support request
Status

Closed: outdated

Version

9.5

Component
SerializationΒ  β†’

Last updated 18 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024