Problem/Motivation

Update dblog_update_10101 fails with SQLite

Steps to reproduce

When upgrading to Drupal 10.1, I couldn't complete the database updates because of this error:


>  [notice] Update started: dblog_update_10101
>  [error]  Unable to parse the column type TINYINT 
>  [error]  Update failed: dblog_update_10101 

This could be because I'm using SQLite instead of MySQL.

Proposed resolution

Follow what was done in #3215062: Update hook_schema for Y2038 and skip for SQLlite.

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

This is also blocking all other database updates.

Issue fork drupal-3370560

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

bogdog400 created an issue. See original summary.

bogdog400’s picture

Is it possible to change out the TINY size for the severity field:

https://api.drupal.org/api/drupal/core%21modules%21dblog%21dblog.install...

 'severity' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
      ],

????

cilefen’s picture

cilefen’s picture

Look into the schema type mappings in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php, in the getFieldTypeMap function.

bogdog400’s picture

When I look there, I see a perfectly good mapping from 'tiny' to "INTEGER.'

This must be somewhere else.

      'int:tiny'        => 'INTEGER',
      'int:small'       => 'INTEGER',
      'int:medium'      => 'INTEGER',
      'int:big'         => 'INTEGER',
      'int:normal'      => 'INTEGER',

https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/sqlit...

catch’s picture

Priority: Normal » Critical

Increasing priority in case this is affecting more installs.

bogdog400’s picture

Does anyone have a suggestion for how I might turn off just this database update? Apparently it used to be possible to do focused updates with drush, but not any more.

TIA

catch’s picture

@bogdog400 if you just want to disable the update, add an early return (i.e. return;) at the top of the function, that way it will be registered as finished and won't run again. Obviously you're on your own for updating the dblog scheme in that case, but for dblog you could uninstall and re-install too.

bogdog400’s picture

Okay. I did that.

It looks like I'm okay until 2038 and the time coordinates get too long. At least that's my guess.

BTW, I looked at uninstalling dblog, but that option isn't available because it's greyed out. The check is locked.

Any suggestions for the best way to update this schema?

catch’s picture

Do you have any modules installed that depend on dblog? It should say why it can't be uninstalled.

Adding a related issue that appears to be the same error. Can you post which version of sqlite you have installed?

bogdog400’s picture

It looks like the migrate module requires it.

Machine name: dblog
Version: 10.1.0
Required by: Migrate Drupal UI (disabled)

But none of the migrate modules can be uninstalled. I'm not sure why.

Database Version 3.37.2
System SQLite

Thx.

bogdog400’s picture

Note: this documentation says that SQLite doesn't have a fixed length.

"In contrast, a SqlLite "integer" can hold whatever you put into it: from a 1-byte char to an 8-byte long long."

https://stackoverflow.com/questions/7337882/what-is-the-difference-betwe...

Does this affect this issue?

catch’s picture

@bogdog400 are you sure you're looking at the uninstall tab and not the main extend listing? You can only uninstall modules from the uninstall tab.

"In contrast, a SqlLite "integer" can hold whatever you put into it: from a 1-byte char to an 8-byte long long."

If this is the case it might be we should entirely skip this update on sqlite - i.e. even if it works flawlessly it'd be a no-op, but I haven't checked this since I'm not supposed to be working today.

bogdog400’s picture

StatusFileSize
new17.52 KB

I put a screen shot below. THere's nothing to uninstall.

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

quietone’s picture

@sonam_sharma, credit has been removed per How is credit granted for Drupal core issues.

cilefen’s picture

IIRC the uninstall UI cannot search by machine name. Try “database”.

bogdog400’s picture

Ah..... yes. That worked. Thanks!

dagmar’s picture

So the problem here is with the update but not with the fresh install? We ran all the tests for Sqlite, Mysql and Postgres https://www.drupal.org/project/drupal/issues/3081144#comment-15012792 is this a lack of tests?

catch’s picture

@bogdog400 can you tell us which sqlite version you're running? (from the status report, to ensure it's the one that PHP is actually using, sometimes there can be multiple sqlite versions on one machine).

bogdog400’s picture

Version
3.37.2
of SQLite

Happy to run other tests too, but I'm on vacation next week.

bogdog400’s picture

BTW, I'm running on an ARM server, in the odd case that might make a difference.

quietone’s picture

Over in #3215062: Update hook_schema for Y2038 daffie explains why it is not necessary to change the field definition for SQLlite integers. Their input starts at #19 and the summary is in #31. For me, that means that the dblog_update_10101 should skip SQLlite as does dblog_update_10100

Adding related issues, including #301038: Add a cross-compatible database schema introspection API which is said to resolve this.

quietone’s picture

Issue summary: View changes

Restoring issue summary

quietone’s picture

Status: Active » Needs review

The failing tests are FunctionalJavascript one so probably random.

Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks
Failed asserting that a NULL is not empty.

daffie’s picture

Status: Needs review » Needs work

Back to needs work.

quietone’s picture

Status: Needs work » Needs review

@daffie, thanks for the review!

I removed the skip so this test will run with all the dbs. Also, ran the tests for all the dbs as well.

Random fail in Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All the changes look good to me.
For me it is RTBC.

  • catch committed 32faa02a on 10.1.x
    Issue #3370560 by quietone, bogdog400, daffie: Update failed:...

  • catch committed 538c90fb on 10.2.x
    Issue #3370560 by quietone, bogdog400, daffie: Update failed:...

  • catch committed cd9dd266 on 11.x
    Issue #3370560 by quietone, bogdog400, daffie: Update failed:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.2.x and 10.1.x, thanks!

Status: Fixed » Closed (fixed)

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