Problem/Motivation

When inline extraction fails, FilesExtractor::queueItem() sets a flag in the search_api_attachments:queued key-value collection and queues the file. FilesExtractor::extractOrGetFromCache() skips inline extraction while that flag is set.

ExtractorQueue::processItem() only clears the flag on success. After the 5th failure it logs and drops the item, but the flag stays:

else {
  $message_params['@message'] = $exception->getMessage();
  $this->logger->log(LogLevel::ERROR, 'Text extraction failed after 5 attempts @file_id for @entity_type @entity_id: @message.', $message_params);
}

So once a file hits 5 failures, inline extraction never runs for it again, even after the extractor is fixed. Happens with any extractor.

Steps to reproduce

  1. Point the Tika server extractor at a port with nothing listening.
  2. Index an entity with a file field. Extraction fails and the file gets queued.
  3. Run cron until the search_api_attachments queue is empty. The log shows "Text extraction failed after 5 attempts".
  4. Fix the extractor config and reindex the entity.
  5. The file is indexed without text, and the flag is still in key_value under search_api_attachments:queued.

Proposed resolution

Clear the flag on the final failure too. The MR moves the existing cleanup into ExtractorQueue::clearQueuedFlag() and calls it from both the success and final-failure paths. Kernel test included.

Remaining tasks

Review the MR.

User interface changes

None

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

j-barnes created an issue. See original summary.

j-barnes’s picture

Status: Active » Needs review

  • j-barnes committed b850a3c8 on 10.0.x
    Issue #3629175: Clear the queued flag after the final failed extraction...
izus’s picture

Assigned: j-barnes » Unassigned
Status: Needs review » Fixed

merged
thanks for this

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

izus’s picture