I get an SQL error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.suggester_id' in 'field list' during the updates (with drush). Patch will follow.

Comments

Jelle_S created an issue. See original summary.

jelle_s’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Assigned: jelle_s » Unassigned
Status: Active » Needs review
StatusFileSize
new1.18 KB

Attached patch fixes the error for me.

drunken monkey’s picture

Status: Needs review » Postponed (maintainer needs more info)

Where is that error triggered, during what update function? Do you have a stack trace, maybe?
Your patch might fix the problem, but it goes completely against the Drupal coding standards, so we definitely can't commit it like this.

Kostya19’s picture

I received this error when updating modules media, webform, field_group, login_destination, diff, userprotect:
Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.suggester_id' in 'field list': SELECT base.id AS id, base.machine_name AS machine_name, base.name AS name, base.index_id AS index_id, base.suggester_id AS suggester_id, base.type AS type, base.enabled AS enabled, base.options AS options, base.status AS status, base.module AS module FROM {search_api_autocomplete_search} base; Array ( ) in EntityAPIController->query() (line 187 of C:\Apache24\htdocs\{...}\sites\all\modules\contrib\entity\includes\entity.controller.inc).

Solution: just run update.php one more time.

drunken monkey’s picture

If you received this error when running update.php (it's not clear from your comment), it seems this is caused by some module ignoring the warning in the official docs and using higher-level APIs within update functions – which is forbidden because it causes exactly such problems.

byrond’s picture

We also experience this error during cache clears after updating Search API to 1.25, Search API Solr Search to 1.14, and Search API Autocomplete to 1.6. Unfortunately, we did all of these concurrently, so I'm not sure which update is the root cause. The only database update was from Search API (Search_api_facetapi 7101 Set up date formats.)

The update seems to have completed successfully, but the error is generated on every cache clear afterward. Here is the full error in the Watchdog log:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.suggester_id' in 'field list': SELECT base.id AS id, base.machine_name AS machine_name, base.name AS name, base.index_id AS index_id, base.suggester_id AS suggester_id, base.type AS type, base.enabled AS enabled, base.options AS options, base.status AS status, base.module AS module FROM {search_api_autocomplete_search} base WHERE (base.status IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => 3 [:db_condition_placeholder_1] => 2 [:db_condition_placeholder_2] => 6 ) in EntityAPIController->query() (line 187 of /var/www/sites/all/modules/contrib/entity/includes/entity.controller.inc).

Here is a stack trace after running drush updb or drush cc all:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column [error]
'base.suggester_id' in 'field list' in
/var/www/includes/database/database.inc:2227
Stack trace:
#0
/var/www/includes/database/database.inc(2227):
PDOStatement->execute(Array)
#1
/var/www/includes/database/database.inc(697):
DatabaseStatementBase->execute(Array, Array)
#2
/var/www/includes/database/select.inc(1280):
DatabaseConnection->query('SELECT base.id ...', Array, Array)
#3
/var/www/sites/all/modules/contrib/entity/includes/entity.controller.inc(187):
SelectQuery->execute()
#4
/var/www/sites/all/modules/contrib/entity/includes/entity.controller.inc(249):
EntityAPIController->query(false, Array, false)
#5
/var/www/sites/all/modules/contrib/entity/includes/entity.controller.inc(730):
EntityAPIController->load(false, Array)
#6
/var/www/includes/common.inc(8019):
EntityAPIControllerExportable->load(false, Array)
#7
/var/www/sites/all/modules/contrib/entity/entity.module(259):
entity_load('search_api_auto...', false, Array)
#8
/var/www/sites/all/modules/contrib/entity/entity.module(888):
entity_load_multiple_by_name('search_api_auto...', false, Array)
#9
/var/www/sites/all/modules/contrib/entity/entity.module(857):
_entity_defaults_rebuild('search_api_auto...')
#10
/var/www/sites/all/modules/contrib/entity/entity.module(1085):
entity_defaults_rebuild()
#11
/var/www/includes/module.inc(957):
entity_flush_caches()
#12
/var/www/includes/common.inc(7682):
module_invoke_all('flush_caches')
#13
/var/www/vendor/drush/drush/commands/core/drupal/cache.inc(99):
drupal_flush_all_caches()
#14
/var/www/vendor/drush/drush/includes/drush.inc(725):
drush_cache_clear_both()
#15
/var/www/vendor/drush/drush/includes/drush.inc(712):
drush_call_user_func_array('drush_cache_cle...', Array)
#16
/var/www/vendor/drush/drush/commands/core/cache.drush.inc(144):
drush_op('drush_cache_cle...')
#17
/var/www/vendor/drush/drush/includes/command.inc(422):
drush_cache_command_clear('all')
#18
/var/www/vendor/drush/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#19
/var/www/vendor/drush/drush/includes/command.inc(199):
drush_command('all')
#20
/var/www/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#21
/var/www/vendor/drush/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#22 /var/www/vendor/drush/drush/drush.php(12):
drush_main()
#23 {main}

I will try to narrow down which of those three updates creates this condition.

byrond’s picture

Component: Code » General code
Status: Postponed (maintainer needs more info) » Active
byrond’s picture

I have narrowed down the appearance of the error to updating Search API Autocomplete to version 1.6 while Search API 1.25 is installed. This happens with or without applying the database update in Search API (mentioned above). Our previous version of this module was 1.1. Rolling back to that version after running drush cc all with 1.6 installed does not eliminate the error. Our previous version of Search API was 1.16, and rolling back to that version doesn't help either.

byrond’s picture

After trying various combinations of versions of Search API (1.16 through 1.25) and Search API Autocomplete (1.3 through 1.6), it seems like this issue may have started with version 1.4 of this module. For now, we are going to stick with the following:

  • Search API 1.25
  • Search API Autocomplete 1.3
  • Search API Solr Search 1.14
drunken monkey’s picture

Category: Bug report » Support request
Status: Active » Fixed

Search API Autocomplete 1.4 does include an update function, namely #7103, which adds exactly the missing search_api_autocomplete_search.suggester_id column. If this update didn’t run on your site, for some reason, it would explain the errors.
Manually re-running the update in some way should resolve this for you (after upgrading to 1.6 again).

drunken monkey’s picture

NB: When upgrading to 1.6, you should actually also get the (unrelated) update #7104. If neither appeared, something strange is going on. But I have no idea how we could have caused this.

Did you maybe do an incomplete update, not successfully replacing the search_api_autocomplete.install file?

byrond’s picture

Thanks for the additional information, @drunken. I can see that search_api_autocomplete.install was updated in our codebase with the update functions, but they weren't run on our site by drush updb for some reason. I'll keep digging and post back here if I find any reason to believe there is an issue with the module. But, it sounds like it's likely an issue with our installation.

byrond’s picture

I eventually found that the schema_version was set to "-1", so no updates were being run. I'm not sure how it got into that state, but setting it to 0 (as described in https://drupal.stackexchange.com/questions/28039/why-is-hook-update-n-no...) allowed drush updb to run all database updates for this module, and I no longer see the error.

Status: Fixed » Closed (fixed)

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