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

  1. Install Drupal 9
  2. 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.
  3. Upgrade to Drupal 10
  4. drush updatedb
  5. 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.

Issue fork drupal-3388170

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

DiDebru created an issue. See original summary.

didebru’s picture

cilefen’s picture

Category: Task » Bug report
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

How did this happen?

didebru’s picture

Good question but unfortunately I don't have an answer yet but with that patch it does not happen.

tetranz’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new783 bytes
new673 bytes

I'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.

smustgrave’s picture

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

We 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.

tetranz’s picture

Issue summary: View changes

I 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.

tetranz’s picture

Status: Postponed (maintainer needs more info) » Needs review
smustgrave’s picture

Status: Needs review » Needs work

If an issue caused by core and not a custom module will need a test case also.

unexjp’s picture

StatusFileSize
new1.73 KB

Our 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.

unexjp’s picture

I 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.

catch’s picture

I 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.

alexpott’s picture

I 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.

alexpott’s picture

Turns 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.

alexpott changed the visibility of the branch 3388170-system-update-10100 to hidden.

alexpott changed the visibility of the branch 10.1.x to hidden.

alexpott’s picture

Status: Needs work » Needs review

Posted an MR with a test.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Just posting here from the MR that alexpott ran

1) Drupal\Tests\system\Functional\Update\Y2038TimestampUpdateTest::testUpdate
The update failed with the following message: "Failed: Drupal\Core\Database\SchemaObjectDoesNotExistException: Cannot change the definition of field 'cache_bogus.expire': field doesn't exist. in Drupal\mysql\Driver\Database\mysql\Schema->changeField() (line 615 of /builds/project/drupal/core/modules/mysql/src/Driver/Database/mysql/Schema.php)."
/builds/project/drupal/core/tests/Drupal/Tests/UpdatePathTestTrait.php:59
/builds/project/drupal/core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php:115
/builds/project/drupal/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
FAILURES!
Tests: 1, Assertions: 36, Failures: 1.

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

  • catch committed 288c0586 on 10.2.x
    Issue #3388170 by DiDebru, tetranz, alexpott, smustgrave: system update...

  • catch committed e8778fb2 on 11.x
    Issue #3388170 by DiDebru, tetranz, alexpott, smustgrave: system update...
catch’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Committed/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.

catch’s picture

Status: Patch (to be ported) » Fixed

Cherry-picked to 10.1.x, we can figure out if/when to release later.

  • catch committed 4948333b on 10.1.x
    Issue #3388170 by DiDebru, tetranz, alexpott, smustgrave: system update...

Status: Fixed » Closed (fixed)

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