Page MenuHomePhabricator

Error 1265: Data truncated for column 'cul_reason_id' at row 1
Closed, ResolvedPublic

Description

Modifying cul_reason_id field of table cu_log...Wikimedia\Rdbms\DBQueryError from line 1534 of /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php: Error 1265: Data truncated for column 'cul_reason_id' at row 1
Function: Wikimedia\Rdbms\Database::sourceFile( /var/www/wiki/mediawiki/extensions/CheckUser/src/../schema/mysql/patch-cu_log-drop-cul_reason_id_default.sql )
Query: ALTER TABLE  `mw_cu_log`
 CHANGE  cul_reason_id cul_reason_id BIGINT UNSIGNED NOT NULL,
 CHANGE  cul_reason_plaintext_id cul_reason_plaintext_id BIGINT UNSIGNED NOT NULL


#0 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1518): Wikimedia\Rdbms\Database->getQueryException()
#1 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1492): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(865): Wikimedia\Rdbms\Database->reportQueryError()
#3 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(3087): Wikimedia\Rdbms\Database->query()
#4 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(3026): Wikimedia\Rdbms\Database->sourceStream()
#5 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->sourceFile()
#6 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(813): Wikimedia\Rdbms\DBConnRef->__call()
#7 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(716): Wikimedia\Rdbms\DBConnRef->sourceFile()
#8 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(998): DatabaseUpdater->applyPatch()
#9 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(547): DatabaseUpdater->modifyField()
#10 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(515): DatabaseUpdater->runUpdates()
#11 /var/www/wiki/mediawiki/core/maintenance/update.php(203): DatabaseUpdater->doUpdates()
#12 /var/www/wiki/mediawiki/core/maintenance/includes/MaintenanceRunner.php(585): UpdateMediaWiki->execute()
#13 /var/www/wiki/mediawiki/core/maintenance/doMaintenance.php(99): MediaWiki\Maintenance\MaintenanceRunner->run()
#14 /var/www/wiki/mediawiki/core/maintenance/update.php(318): require_once('...')
#15 {main}

MariaDB [wikidb]> explain mw_cu_log;
+-------------------------+---------------------+------+-----+---------+----------------+
| Field                   | Type                | Null | Key | Default | Extra          |
+-------------------------+---------------------+------+-----+---------+----------------+
| cul_id                  | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| cul_timestamp           | binary(14)          | NO   | MUL | NULL    |                |
| cul_reason_id           | bigint(20) unsigned | YES  |     | NULL    |                |
| cul_reason_plaintext_id | bigint(20) unsigned | YES  |     | NULL    |                |
| cul_type                | varbinary(30)       | NO   | MUL | NULL    |                |
| cul_target_id           | int(10) unsigned    | NO   |     | 0       |                |
| cul_target_text         | blob                | NO   |     | NULL    |                |
| cul_target_hex          | varbinary(255)      | NO   | MUL |         |                |
| cul_range_start         | varbinary(255)      | NO   | MUL |         |                |
| cul_range_end           | varbinary(255)      | NO   |     |         |                |
| cul_actor               | bigint(20) unsigned | NO   | MUL | NULL    |                |
+-------------------------+---------------------+------+-----+---------+----------------+
11 rows in set (0.001 sec)

MariaDB [wikidb]> show indexes from mw_cu_log;
+-----------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| Table     | Non_unique | Key_name        | Seq_in_index | Column_name     | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
+-----------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| mw_cu_log |          0 | PRIMARY         |            1 | cul_id          | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_timestamp   |            1 | cul_timestamp   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_type_target |            1 | cul_type        | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_type_target |            2 | cul_target_id   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_type_target |            3 | cul_timestamp   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_target_hex  |            1 | cul_target_hex  | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_target_hex  |            2 | cul_timestamp   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_range_start |            1 | cul_range_start | A         |           2 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_range_start |            2 | cul_timestamp   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_actor_time  |            1 | cul_actor       | A         |           2 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| mw_cu_log |          1 | cul_actor_time  |            2 | cul_timestamp   | A         |           6 |     NULL | NULL   |      | BTREE      |         |               | NO      |
+-----------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
11 rows in set (0.001 sec)

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

I'm guessing it's the NOT NULL part; all the rows for cul_reason_id are NULL.

Same for cul_reason_plaintext_id if it hadn't errored out by that point..

That's odd because the maintenance script that fills the entries should have run before that point. Can you share the full update.php log?

*******************************************************************************
NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!
      Running scripts directly has been deprecated in MediaWiki 1.40.
      It may not work for some (or any) scripts in the future.
*******************************************************************************

MediaWiki 1.40.0-alpha Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for wikidb-mw_
Depending on the size of your database this may take a while!
...collations up-to-date.
...have rev_actor field in revision table.
...ar_usertext_timestamp key doesn't exist.
...usertext_timestamp key doesn't exist.
...archive table does not contain ar_user field.
...ipblocks table does not contain ip_by field.
...img_user_timestamp key doesn't exist.
...image table does not contain img_user field.
...oldimage table does not contain oi_user field.
...filearchive table does not contain fa_user field.
...recentchanges table does not contain rc_user field.
...logging table does not contain log_user field.
...index un_user_ip already set on user_newtalk table.
...watchlist_expiry table already exists.
...page_restrictions field does not exist in page table, skipping modify field patch.
...index ipb_address_unique already set on ipblocks table.
...archive table does not contain ar_text_id field.
...lc_lang is up-to-date.
...ll_lang is up-to-date.
...site_language is up-to-date.
...index ipb_address_unique on table ipblocks has no field ipb_anon_only; added.
...ipb_address_unique index up-to-date.
...actor_name in table actor already modified by patch patch-actor-actor_name-varbinary.sql.
...site_global_key in table sites already modified by patch patch-sites-site_global_key.sql.
...iwl_prefix in table iwlinks already modified by patch patch-extend-iwlinks-iwl_prefix.sql.
...rd_title in table redirect already modified by patch patch-redirect-rd_title-varbinary.sql.
...pl_title in table pagelinks already modified by patch patch-pagelinks-pl_title-varbinary.sql.
...tl_title field does not exist in templatelinks table, skipping modify field patch.
...il_to in table imagelinks already modified by patch patch-imagelinks-il_to-varbinary.sql.
...ll_title in table langlinks already modified by patch patch-langlinks-ll_title-varbinary.sql.
...iwl_title in table iwlinks already modified by patch patch-iwlinks-iwl_title-varbinary.sql.
...cat_title in table category already modified by patch patch-category-cat_title-varbinary.sql.
...qc_title in table querycache already modified by patch patch-querycache-qc_title-varbinary.sql.
...qcc_title in table querycachetwo already modified by patch patch-querycachetwo-qcc_title-varbinary.sql.
...wl_title in table watchlist already modified by patch patch-watchlist-wl_title-varbinary.sql.
...user_last_timestamp in table user_newtalk already modified by patch patch-user_newtalk-user_last_timestamp-binary.sql.
...pt_title in table protected_titles already modified by patch patch-protected_titles-pt_title-varbinary.sql.
...ir_type in table ipblocks_restrictions already modified by patch patch-ipblocks_restrictions-ir_type.sql.
...index wl_namespace_title already set on watchlist table.
...job_title in table job already modified by patch patch-job-job_title-varbinary.sql.
...job_timestamp in table job already modified by patch patch-job_job_timestamp.sql.
...job_token_timestamp in table job already modified by patch patch-job_job_token_timestamp.sql.
...wl_notificationtimestamp in table watchlist already modified by patch patch-watchlist-wl_notificationtimestamp.sql.
...role_id in table slot_roles already modified by patch patch-slot_roles-role_id.sql.
...model_id in table content_models already modified by patch patch-content_models-model_id.sql.
...cl_to in table categorylinks already modified by patch patch-categorylinks-cl_to-varbinary.sql.
...log_title in table logging already modified by patch patch-logging-log_title-varbinary.sql.
...us_timestamp in table uploadstash already modified by patch patch-uploadstash-us_timestamp.sql.
...index up_property already set on user_properties table.
...index site_global_key already set on sites table.
...index log_type_time already set on logging table.
...fa_name in table filearchive already modified by patch patch-filearchive-fa_name.sql.
...oi_name in table oldimage already modified by patch patch-oldimage-oi_name-varbinary.sql.
...exptime in table objectcache already modified by patch patch-objectcache-exptime-notnull.sql.
...index ar_name_title_timestamp already set on archive table.
...img_name in table image already modified by patch patch-image-img_name-varbinary.sql.
...img_timestamp in table image already modified by patch patch-image-img_timestamp.sql.
...index si_key already set on site_identifiers table.
...rc_title in table recentchanges already modified by patch patch-recentchanges-rc_title-varbinary.sql.
...rc_timestamp in table recentchanges already modified by patch patch-recentchanges-rc_timestamp.sql.
...rc_id in table recentchanges already modified by patch patch-recentchanges-rc_id.sql.
...index rc_new_name_timestamp already set on recentchanges table.
...ar_title in table archive already modified by patch patch-archive-ar_title-varbinary.sql.
...page_title in table page already modified by patch patch-page-page_title-varbinary.sql.
...user_name in table user already modified by patch patch-user_table-updates.sql.
...index rev_page_timestamp already set on revision table.
...have modtoken field in objectcache table.
...index oi_timestamp already set on oldimage table.
...index page_name_title already set on page table.
...index ct_rc_tag_id already set on change_tag table.
...page_restrictions table does not contain pr_user field.
...fa_id in table filearchive already modified by patch patch-filearchive-fa_id.sql.
...img_major_mime in table image already modified by patch patch-image-img_major_mime-default.sql.
...linktarget table already exists.
...rev_page_id key doesn't exist.
...pr_page in table page_restrictions already modified by patch patch-page_restrictions-pr_page.sql.
...pp_page in table page_props already modified by patch patch-page_props-pp_page.sql.
...ir_value in table ipblocks_restrictions already modified by patch patch-ipblocks_restrictions-ir_value.sql.
...have tl_target_id field in templatelinks table.
...user_autocreate_serial table already exists.
...ir_ipb_id in table ipblocks_restrictions already modified by patch patch-ipblocks_restrictions-ir_ipb_id.sql.
...ipb_id in table ipblocks already modified by patch patch-ipblocks-ipb_id.sql.
...user_editcount in table user already modified by patch patch-user-user_editcount.sql.
Running maintenance/migrateRevisionActorTemp.php...
...Update 'MigrateRevisionActorTemp' already logged as completed. Use --force to run it again.
done.
...revision_actor_temp doesn't exist.
Running maintenance/updateRestrictions.php...
Migration is not needed.
done.
...page table does not contain page_restrictions field.
...templatelinks table has already been migrated.
...tl_namespace field does not exist in templatelinks table, skipping modify field patch.
...templatelinks table does not contain tl_title field.
...have el_to_path field in externallinks table.
...code_rev table already exists.
...have cr_diff field in code_rev table.
...index repo_to_from already set on code_relations table.
...code_bugs table already exists.
...code_signoffs table already exists.
...have cs_user field in code_signoffs table.
...have cs_timestamp_struck field in code_signoffs table.
...index cc_author already set on code_comment table.
...index cpc_author already set on code_prop_changes table.
...index repo_path already set on code_paths table.
...index cr_repo_status_author already set on code_rev table.
...code_comment table does not contain cc_review field.
...code_test_suite doesn't exist.
...have ca_user field in code_authors table.
...ca_repo_author key doesn't exist.
...babel table already exists.
...babel_lang in table babel already modified by patch /var/www/wiki/mediawiki/extensions/Babel/sql/babel-babel_lang-length-type.sql.
...babel_level in table babel already modified by patch /var/www/wiki/mediawiki/extensions/Babel/sql/babel-babel_level-type.sql.
...uw_campaigns table already exists.
...uw_campaigns_enabled field does not exist in uw_campaigns table, skipping modify field patch.
...shorturls table already exists.
...urlshortcodes table already exists.
...have usc_deleted field in urlshortcodes table.
...wikilove_log table already exists.
...wll_timestamp in table wikilove_log already modified by patch /var/www/wiki/mediawiki/extensions/WikiLove/patches/patch-wikilove_log-cleanup.sql.
...translate_sections table already exists.
...revtag table already exists.
...translate_groupstats table already exists.
...translate_reviews table already exists.
...translate_groupreviews table already exists.
...translate_tms table already exists.
...translate_metadata table already exists.
...translate_messageindex table already exists.
...translate_stash table already exists.
...translate_translatable_bundles table already exists.
...index PRIMARY already set on translate_reviews table.
...translate_cache table already exists.
...tc_key in table translate_cache already modified by patch /var/www/wiki/mediawiki/extensions/Translate/sql/mysql/translate_cache-alter-varbinary.sql.
...tmi_key key doesn't exist.
...tms_sid_lang key doesn't exist.
...rt_type_page_revision key doesn't exist.
...spoofuser table already exists.
...index su_normname_idx already set on spoofuser table.
...pr_index table already exists.
...globalblocks table already exists.
...global_block_whitelist table already exists.
...gb_reason in table globalblocks already modified by patch /var/www/wiki/mediawiki/extensions/GlobalBlocking/includes/../sql/mysql/patch-globalblocks-reason-length.sql.
...gbw_reason in table global_block_whitelist already modified by patch /var/www/wiki/mediawiki/extensions/GlobalBlocking/includes/../sql/mysql/patch-global_block_whitelist-reason-length.sql.
...gbw_by_text in table global_block_whitelist already modified by patch /var/www/wiki/mediawiki/extensions/GlobalBlocking/includes/../sql/mysql/patch-global_block_whitelist-use-varbinary.sql.
...have gb_by_central_id field in globalblocks table.
...gb_anon_only in table globalblocks already modified by patch /var/www/wiki/mediawiki/extensions/GlobalBlocking/includes/../sql/mysql/patch-globalblocks-gb_anon_only.sql.
...gb_expiry in table globalblocks already modified by patch /var/www/wiki/mediawiki/extensions/GlobalBlocking/includes/../sql/mysql/patch-globalblocks-timestamps.sql.
...echo_event table already exists.
Running extensions/Echo/maintenance/updateEchoSchemaForSuppression.php...
...Update 'UpdateEchoSchemaForSuppression' already logged as completed. Use --force to run it again.
done.
...echo_event table does not contain event_page_namespace field.
...echo_event table does not contain event_page_title field.
...echo_notification table does not contain notification_bundle_base field.
...echo_notification table does not contain notification_bundle_display_hash field.
...echo_notification_user_hash_timestamp key doesn't exist.
...echo_push_provider table already exists.
...echo_push_subscription table already exists.
...echo_push_topic table already exists.
...index eps_user already set on echo_push_subscription table.
...echo_push_subscription_token key doesn't exist.
...index eps_token already set on echo_push_subscription table.
...have eps_topic field in echo_push_subscription table.
...echo_unread_wikis table already exists.
...euw_wiki in table echo_unread_wikis already modified by patch /var/www/wiki/mediawiki/extensions/Echo/sql/mysql/patch-increase-varchar-echo_unread_wikis-euw_wiki.sql.
...bounce_records table already exists.
...br_timestamp in table bounce_records already modified by patch /var/www/wiki/mediawiki/extensions/BounceHandler/sql/mysql/patch-bounce_records-br_timestamp.sql.
...petition_data table already exists.
...throttle_override table already exists.
...index thr_expiry already set on throttle_override table.
...have thr_target field in throttle_override table.
...flow_revision table already exists.
...ref_src_wiki in table flow_wiki_ref already modified by patch /var/www/wiki/mediawiki/extensions/Flow/sql/mysql/patch-increase-varchar-flow_wiki_ref-ref_src_wiki.sql.
...ref_src_wiki in table flow_ext_ref already modified by patch /var/www/wiki/mediawiki/extensions/Flow/sql/mysql/patch-increase-varchar-flow_ext_ref-ref_src_wiki.sql.
...rev_mod_timestamp in table flow_revision already modified by patch /var/www/wiki/mediawiki/extensions/Flow/sql/mysql/patch-flow_revision-rev_mod_timestamp.sql.
...flaggedimages doesn't exist.
...flaggedrevs table already exists.
...flaggedtemplates table does not contain ft_title field.
...flaggedrevs table does not contain fr_img_name field.
...flaggedpage_config table does not contain fpc_select field.
...ft_tmp_rev_id in table flaggedtemplates already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedtemplates-ft_tmp_rev_id.sql.
...fp_pending_since in table flaggedpages already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedpages-timestamp.sql.
...fpp_pending_since in table flaggedpage_pending already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedpage_pending-timestamp.sql.
...fr_timestamp in table flaggedrevs already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedrevs-timestamps.sql.
...frs_timestamp in table flaggedrevs_statistics already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedrevs_statistics-timestamp.sql.
...fpc_expiry in table flaggedpage_config already modified by patch /var/www/wiki/mediawiki/extensions/FlaggedRevs/backend/schema/mysql/patch-flaggedpage_config-timestamp.sql.
...frt_from_namespace_title key doesn't exist.
...mathoid table already exists.
...mathlatexml table already exists.
...have math_png field in mathoid table.
...globalimagelinks table already exists.
...globalimagelinks_to_wiki_page key doesn't exist.
...nl_newsletters table already exists.
...wikimedia_editor_tasks_keys table already exists.
...wikimedia_editor_tasks_edit_streak table already exists.
...wikimedia_editor_tasks_entity_description_exists doesn't exist.
...wikimedia_editor_tasks_targets_passed doesn't exist.
...have wetc_revert_count field in wikimedia_editor_tasks_counts table.
...reading_list table already exists.
...reading_list_sortkey doesn't exist.
...reading_list_project table already exists.
...index rl_user_deleted_name_id already set on reading_list table.
...reading_list table does not contain rl_color field.
...rle_title in table reading_list_entry already modified by patch /var/www/wiki/mediawiki/extensions/ReadingLists/sql/mysql/patches/05-increase-rle_title-length.sql.
...have rl_size field in reading_list table.
...cu_changes table already exists.
...cuc_id in table cu_changes already modified by patch /var/www/wiki/mediawiki/extensions/CheckUser/src/../schema/mysql/patch-cu_changes-cuc_id-unsigned.sql.
...index cuc_actor_ip_time already set on cu_changes table.
...cuc_timestamp in table cu_changes already modified by patch /var/www/wiki/mediawiki/extensions/CheckUser/src/../schema/mysql/patch-cu_changes-cuc_timestamp.sql.
...have cul_reason_id field in cu_log table.
...have cul_actor field in cu_log table.
Running extensions/CheckUser/maintenance/populateCulActor.php...
...Update 'PopulateCulActor-2' already logged as completed. Use --force to run it again.
done.
Running extensions/CheckUser/maintenance/populateCulComment.php...
...Update 'PopulateCulComment' already logged as completed. Use --force to run it again.
done.
Running extensions/CheckUser/maintenance/populateCucActor.php...
...Update 'PopulateCucActor' already logged as completed. Use --force to run it again.
done.
...cu_log_event table already exists.
...cu_private_event table already exists.
...cul_user field does not exist in cu_log table, skipping modify field patch.
Modifying cul_reason field of table cu_log...done.
Modifying cul_reason_id field of table cu_log...Wikimedia\Rdbms\DBQueryError from line 1534 of /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php: Error 1265: Data truncated for column 'cul_reason_id' at row 1
Function: Wikimedia\Rdbms\Database::sourceFile( /var/www/wiki/mediawiki/extensions/CheckUser/src/../schema/mysql/patch-cu_log-drop-cul_reason_id_default.sql )
Query: ALTER TABLE  `mw_cu_log`
 CHANGE  cul_reason_id cul_reason_id BIGINT UNSIGNED NOT NULL,
 CHANGE  cul_reason_plaintext_id cul_reason_plaintext_id BIGINT UNSIGNED NOT NULL


#0 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1518): Wikimedia\Rdbms\Database->getQueryException()
#1 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1492): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(865): Wikimedia\Rdbms\Database->reportQueryError()
#3 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(3087): Wikimedia\Rdbms\Database->query()
#4 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(3026): Wikimedia\Rdbms\Database->sourceStream()
#5 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->sourceFile()
#6 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(813): Wikimedia\Rdbms\DBConnRef->__call()
#7 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(716): Wikimedia\Rdbms\DBConnRef->sourceFile()
#8 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(998): DatabaseUpdater->applyPatch()
#9 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(547): DatabaseUpdater->modifyField()
#10 /var/www/wiki/mediawiki/core/includes/installer/DatabaseUpdater.php(515): DatabaseUpdater->runUpdates()
#11 /var/www/wiki/mediawiki/core/maintenance/update.php(203): DatabaseUpdater->doUpdates()
#12 /var/www/wiki/mediawiki/core/maintenance/includes/MaintenanceRunner.php(585): UpdateMediaWiki->execute()
#13 /var/www/wiki/mediawiki/core/maintenance/doMaintenance.php(99): MediaWiki\Maintenance\MaintenanceRunner->run()
#14 /var/www/wiki/mediawiki/core/maintenance/update.php(318): require_once('...')
#15 {main}

Seems that "PopulateCulComment" was already run based on that log. I'm guessing that because the values were NULL (and not 0) the rows were not selected. The population script can be updated to also select rows if the value is NULL.

The definition of these columns in schema/mysql/patch-cu_log-comment_table_for_reason.sql is as follows:

ALTER TABLE  /*_*/cu_log
ADD  cul_reason_id BIGINT UNSIGNED DEFAULT 0 NOT NULL,
ADD  cul_reason_plaintext_id BIGINT UNSIGNED DEFAULT 0 NOT NULL;

However, what I think happened was that you updated the DB when https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/800827 was still not reverted (as that had the rows as nullable). There is a two day window when this was in the master branch (reverted a few days later) and this was never in a wmf branch or on a release branch.

Thankfully this was just a testing wiki (so loosing the reasons for checks on that wiki is not a big deal) but two things that I think should be done here:

  • Update the PopulateCulComment maintenance script to also select rows that are NULL
  • Move the removal of cul_reason to under the final modification to cul_reason_id / cul_reason_plaintext_id.

These fixes would only be needed for wikis that pulled changes for CheckUser on the master branch between 4th of June 2022 to 6th of June 2022.

However, what I think happened was that you updated the DB when https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/800827 was still not reverted (as that had the rows as nullable). There is a two day window when this was in the master branch (reverted a few days later) and this was never in a wmf branch or on a release branch.

Aha, that would sound very likely, yeah. I tend to update my dev wiki most days (which includes running schema changes).

Thankfully this was just a testing wiki

My dev wiki is very very important ;)

Thankfully this was just a testing wiki (so loosing the reasons for checks on that wiki is not a big deal) but two things that I think should be done here:

  • Update the PopulateCulComment maintenance script to also select rows that are NULL
  • Move the removal of cul_reason to under the final modification to cul_reason_id / cul_reason_plaintext_id.

These fixes would only be needed for wikis that pulled changes for CheckUser on the master branch between 4th of June 2022 to 6th of June 2022.

I probably didn't even enter any reasons (unless CU forces you?).

If you update PopulateCulComment script you might want to update the update key (mark it as "-v2" or something) so it runs again without being needing to be forced. Could rename the class, but probably not worth it.

Sounds like a reasonable path forward though, happy to help test.

Change 886455 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@master] Handle rare case that cul_reason_id is NULL

https://gerrit.wikimedia.org/r/886455

Dreamy_Jazz triaged this task as Medium priority.
Dreamy_Jazz moved this task from General / Unsorted to Patches for review on the CheckUser board.

In the end that patch:

  • Updates the population script to also select rows for migration that have cul_reason_id as NULL
  • The SQL file to remove the default for cul_reason_id / cul_reason_plaintext_id also updates to be a NOT NULL constraint for mysql and sqlite. This is not done for postgres, so specific updates are added to handle any postgres testing wikis.

I did not move the removal of cul_reason to below the removal of the default as for sqlite the order in which they are added is important due to the creation of temporary tables.

Change 886455 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Handle rare case that cul_reason_id is NULL

https://gerrit.wikimedia.org/r/886455

Dreamy_Jazz closed this task as Resolved.EditedFeb 4 2023, 11:26 PM

I think this can be marked as resolved.

Running update.php for a wiki that still has cul_reason but has cul_reason_id values of NULL will be properly converted. For wikis where cul_reason doesn't exist anymore and where there are NULL values for cul_reason_id, the database will need to be manually fixed using the following steps:

  • Find the comment table row where comment_text is the empty string - SELECT comment_id FROM comment WHERE comment_text = '';
  • Update all NULL values of cul_reason_id / cul_reason_plaintext_id with this comment table ID (example query assumes the empty comment row had the ID 1) - UPDATE cul_reason_id = 1, cul_reason_plaintext_id = 1 WHERE cul_reason_id IS NULL OR cul_reason_plaintext_id IS NULL;
  • Re-run update.php - This should go without error and Special:CheckUserLog will display the affected rows with no reason for the check.

If wanted I can make a separate patch to do this as part of update.php. I haven't done so as a user would have hit an error running update.php for the steps above to be needed, and as this is the first sign of this error presumably this is the only wiki with this problem.

If there is need for this script, please re-open and ping me.

  • Update all NULL values of cul_reason_id / cul_reason_plaintext_id with this comment table ID (example query assumes the empty comment row had the ID 1) - UPDATE cul_reason_id = 1, cul_reason_plaintext_id = 1 WHERE cul_reason_id IS NULL OR cul_reason_plaintext_id IS NULL;

Just for anyone that stumbles across this, this isn't valid SQL, you need to run:

UPDATE cu_log SET cul_reason_id = 1, cul_reason_plaintext_id = 1 WHERE cul_reason_id IS NULL OR cul_reason_plaintext_id IS NULL;

And in both queries (the SELECT too), adjust comment and cu_log to account for your table prefix if you have one

Oh good point. Thanks for noting that.