Problem/Motivation
Error Output:
================
> [notice] Update started: system_update_10100
> [error] Cannot change the definition of field 'cache_graphql.definitions.expire': field doesn't exist.
> [error] Update failed: system_update_10100
[error] Update aborted by: system_update_10100
[error] Finished performing updates.
Steps to reproduce
- Install Drupal 9
- Create a database table with a name that begins with cache_. Do not have a column named expire. This table could be created in a custom module with hook_schema() or created with a SQL tool or whatever.
- Upgrade to Drupal 10
- drush updatedb
- system_update_10100 will crash with "field doesn't exist".
Proposed resolution
In systrem.install on line 1800 after the foreach statement check if the cache table exist.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3388170
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
Comment #2
didebruComment #3
cilefen commentedHow did this happen?
Comment #4
didebruGood question but unfortunately I don't have an answer yet but with that patch it does not happen.
Comment #5
tetranz commentedI've updated this to check if the table has an expire column. I got this error on a site which has a custom table with a name starting with cache_ but it does not have an expire column. It is used as a cache which never expires.
I left DiDebru's check there but I don't really see how the table could not exist. I think that would give a different error message.
Comment #6
smustgrave commentedWe still would need steps that caused this to happen. I did a 9.5 to 10.1 update just yesterday funny enough but did not hit this error. I hit a separate issue and turned out one of the custom modules had a problem. So wonder if that's the case here too.
Comment #7
tetranz commentedI added some steps to reproduce.
It was probably a bad choice of custom table name some time ago but I don't think it is set in stone that any table beginning with cache_ must have an expire column. That is what system_update_10100 assumes.
Comment #8
tetranz commentedComment #9
smustgrave commentedIf an issue caused by core and not a custom module will need a test case also.
Comment #10
unexjp commentedOur team ran into this issue and it hung after using the above patch. After looking into the update hook a bit further we compared changeField to watchdog's use of changefield and noticed a difference.
We changed
$schema->changeField('sessions', 'timestamp', 'timestamp', $new);to
$connection->schema()->changeField('sessions', 'timestamp', 'timestamp', $new);Attached is a patch for 10.1.6. I couldn't grab the branch that the issue was applied to, but at least our patch is here for others to bypass this problem.
Comment #11
unexjp commentedI wanted to repost that our issue was more to do with the size of the tables. In our case the size of our queue tables were substantial, but after truncating the tables we were able to upgrade with no issues.
Comment #12
catchI don't think this needs explicit test coverage - we would have to make an additional database dump, with a custom/bogus cache_something table, then update that dump in the update test, to show that we don't get an error. Since we already test the update without such a table, we have implicit test coverage of the if statements in the usual case anyway.
However this could use the patch in #5 converted to an MR, and if possible I'd like to get this committed before 10.2.0's release next week.
Comment #13
alexpottI think we could build the list of cache bins from the container - or maybe even get it from there. And then we wouldn't be potentially touch other tables.
Comment #14
alexpottTurns out #13 was optimistic because cache.container is not tagged and therefore not returned by Cache::getBins() - I'm pretty sure this is on purpose... but considering this is possible going for something simliar to #5 seems good.
Comment #18
alexpottPosted an MR with a test.
Comment #19
smustgrave commentedJust posting here from the MR that alexpott ran
So test coverage appears to be there, applied the MR locally and can run the update just fine. Hope it can make it to 10.2
Comment #22
catchCommitted/pushed to 11.x and 10..2.x, thanks!
10.1.x has had its last security release, so we need to decide what to do there a bit.
Comment #23
catchCherry-picked to 10.1.x, we can figure out if/when to release later.