Problem/Motivation

On some sites (I cannot make out any relevant difference between those that work and those that don't), an update to 8.x-1.21 is not successful because of the following error:

$ drush -l mydomain.at updb
 ------------ ----------- --------------- --------------------------------
  Module       Update ID   Type            Description
 ------------ ----------- --------------- --------------------------------
  search_api   8107        hook_update_n   Add a unique index to the task
                                           entity type's storage.
  search_api   8108        hook_update_n   Add configuration for boost
                                           factors.
  search_api   8109        hook_update_n   Enable index entity references
                                           option by default on existing
                                           indexes.
 ------------ ----------- --------------- --------------------------------


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 >

>  [notice] Update started: search_api_update_8107
>  [error]  Call to a member function setHandlerClass() on null
>  [error]  Update failed: search_api_update_8107
 [error]  Update aborted by: search_api_update_8107
 [error]  Finished performing updates.

No amount of --verbose or --debug or looking at log files gives any more clues as to what exactly happens/goes wrong.

This only happens on sites where search_api and search_api_db are enabled but not yet configured (this is work in progress) - but this may be unrelevant. There are sites on the same multisite installation that have unconfigured search_api and search_api_db as well that update their DB flawlessly. I'm really at a loss as to what can be the difference.

Steps to reproduce

Just drush updb after an update from 8.x-1.20 to 8.x-1.21.

I changed to

innodb_large_prefix=on
innodb_default_row_format=dynamic

on MariaDB 10.1.48, restarted MariaDB, and did an
ALTER TABLE `<tablename>` ROW_FORMAT=Dynamic;
to all the tables before to fix https://www.drupal.org/project/search_api/issues/3247781. I don't know if this is relevant. As I already said, all other sites except 3 got the same treatment and it worked out flawlessly. Therefore I'm not adding the issue as related yet.

An uninstall/enable cycle fixes it for me.

Issue fork search_api-3248262

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:

  • 3248262-call-to-a Comparecompare

Comments

tgoeg created an issue. See original summary.

tgoeg’s picture

Alright, so this seems unrelated to the row format update.

On another server running MySQL 5.7.36, no row format update was needed.
Only 1 site showed the problem.

Something strange happens when trying to uninstalling/installing search_api:

$ drush -l $site pm:uninstall search_api_db search_api && drush -l $site pm:enable search_api_db search_api && drush -l $site updb -y
 [success] Successfully uninstalled: search_api_db, search_api
>  [notice] Checked de translation for search_api.
>  [error]  The specified file 'temporary://filecBGNEE' could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions.
>  [error]  Unable to download translation file https://ftp.drupal.org/files/translations/all/search_api/search_api-8.x-1.21.de.po.
>  [warning] fopen(translations://search_api-8.x-1.21.de.po): failed to open stream: "Drupal\locale\StreamWrapper\TranslationsStream::stream_open" call failed PoStreamReader.php:154
>  [warning] fgets() expects parameter 1 to be resource, boolean given PoStreamReader.php:248
>  [notice] Unable to import translations file: translations://search_api-8.x-1.21.de.po
>  [error]  Message: Failed to save file due to error "/The specified file
> 'temporary://filecBGNEE' could not be copied because the destination
> directory is not properly configured. This may be caused by a problem with
> file or directory permissions./"
>
>  [error]  Message: 2 Übersetzungsdateien konnten nicht importiert werden. Das Protokoll
> enthält Details.
>
 [success] Successfully enabled: search_api_db, search_api
 [success] No pending updates.

The temp dir is at /tmp and is of course writable, working flawlessly on all sites.

Running the same command a second time works:

$ drush -l $site pm:uninstall search_api_db search_api && drush -l $site pm:enable search_api_db search_api && drush -l $site updb -y
 [success] Successfully uninstalled: search_api_db, search_api
>  [notice] Checked de translation for search_api.
>  [notice] Downloaded de translation for search_api.
>  [notice] Importing de translation for search_api. (8%).
>  [notice] Importing de translation for search_api. (29%).
>  [notice] Importing de translation for search_api. (52%).
>  [notice] Importing de translation for search_api. (85%).
>  [notice] Imported de translation for search_api.
>  [notice] Translations imported: 764 added, 110 updated, 0 removed.
>  [notice] Message: Übersetzungsdatei wurde importiert. /764/ Übersetzungen wurden
> hinzugefügt, /110/ Übersetzungen wurden aktualisiert und /0/ Übersetzungen
> wurden entfernt.
>
 [success] Successfully enabled: search_api_db, search_api
 [success] No pending updates.

So reinstallation worked here as well, but I am completely clueless as to what this error might be and whether it might cause the initial error.

Robert_T made their first commit to this issue’s fork.

Robert_T’s picture

I had the same issue on a website after an update from 8.x-1.20 to 8.x-1.21. Table search_api_task is empty, which seems to indicate that there are no search_api_task objects, so the update fails.

This patch did the trick for me.

mikebarkas’s picture

I updated from 1.20 to 1.21 and got the same drush updb error.

I had an empty search_api_task table as well and applied @Robert_T patch.

Patch #4 worked for me, allowed me to run drush updb.

drunken monkey’s picture

Status: Active » Needs review
Related issues: +#3260230: Error on search_api_update_8110
StatusFileSize
new2.97 KB

Thanks a lot for reporting this problem!
I don’t really see what the contents of the search_api_task table would have to do with this, but yes, if $entity_type can in some cases be NULL, I guess we should just check for that.

However, as also discussed in #3260230-6: Error on search_api_update_8110, this update function has actually become superfluous in the meantime – there is already another update function, 8110, which just undoes it. So, we might as well remove the whole function code – but should then, of course, similarly guard the 8110 update function against this problem. (Also, I guess, no need to do anything if no handler was actually set in 8107?)

The attached patch would implement this, please test/review!

drunken monkey’s picture

Priority: Normal » Major
samlerner’s picture

I ran into this problem on Acquia Cloud, and neither this patch nor ones on https://www.drupal.org/project/search_api/issues/3260230 did the trick.

However, I DID manage to fix things by disabling search_api, running database updates, and then re-enabling it and all its dependent modules.

drush pmu search_api
drush updb -y
drush en search_api search_api_solr acquia_search etc....

Given the error looks like this bug in MySQL tables the only other fix would be a full database restore, which would rebuild the tables, and allow the database updates to work. This is why it was working for me in lower Acquia environments, but failed on production.

drunken monkey’s picture

Status: Needs review » Fixed

Well, once the database update has run, this patch will of course not help with the problem. Still, it shouldn’t do any harm (I sincerely hope) and help prevent problems for people who are late in upgrading. (Seems like about half of D8 users is still on version 1.20 or below, meaning they still need to make this update.)

I don’t think there is much more to do for this ticket, anything else should be done either in #3260230: Error on search_api_update_8110 or in a new ticket.

Status: Fixed » Closed (fixed)

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