Page MenuHomePhabricator

Remove default on cul_reason_id and cul_reason_plaintext_id in the cu_log table on wmf wikis
Closed, ResolvedPublic

Description

  1. ALTERs to run: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/CheckUser/+/035006407f3f9a054ed86d6c42a23c1486b41e88/schema/mysql/patch-cu_log-drop-cul_reason_id_default.sql
  2. Where to run those changes: all
  3. When to run those changes: At any time
  4. If the schema change is backwards compatible: Yes
  5. If the schema change has been tested already on some of the test/beta wikis: beta cluster doesn't have checkuser - tested locally
  6. If the data should be made available on the labs replicas and/or dumps: Everything is private

Comment table migration is complete for cu_log, so there no longer needs to be a default for these two rows as they will always be filled with a value on an INSERT.

If it makes things easier, this could be done at the same time as T328807 because dropping cul_reason means that these columns must have a value.

Progress

  • s1
  • s2
  • s3
  • s4
  • s5
  • s6
  • s7
  • s8
  • labtestwiki

Event Timeline

Deployed and tested on https://checkuser-beta-wiki.wmcloud.org:

  • pull latest origin & vagrant git-update
  • describe cu_log
  • Run a check
    • Debug log looks fine (queries to INSERT always specify cul_reason_id and cul_reason_plaintext_id)
  • Load Special:CheckUserLog
    • No errors seen

Describe of cu_log after update.php run

(02:24) vagrant@localhost:[wiki]> describe 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_actor               | bigint(20) unsigned | NO   | MUL | NULL    |                |
| cul_reason_id           | bigint(20) unsigned | NO   |     | NULL    |                |
| cul_reason_plaintext_id | bigint(20) unsigned | NO   |     | 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   |     |         |                |
+-------------------------+---------------------+------+-----+---------+----------------+
11 rows in set (0.002 sec)

Extract of debug log showing the INSERT queries being run
Check with a reason:

[rdbms] MediaWiki\CheckUser\CheckUserLogService::addLogEntry [0.001s] 127.0.0.1: INSERT INTO `cu_log` (cul_timestamp,cul_actor,cul_type,cul_target_id,cul_target_text,cul_target_hex,cul_range_start,cul_range_end,cul_reason_id,cul_reason_plaintext_id) VALUES ('20230204022611',1,'userips',1,'Admin','','','',13,13)

Check with empty reason:

[rdbms] MediaWiki\CheckUser\CheckUserLogService::addLogEntry [0.001s] 127.0.0.1: INSERT INTO `cu_log` (cul_timestamp,cul_actor,cul_type,cul_target_id,cul_target_text,cul_target_hex,cul_range_start,cul_range_end,cul_reason_id,cul_reason_plaintext_id) VALUES ('20230204022614',1,'userips',1,'Admin','','','',1,1)
Dreamy_Jazz renamed this task from Remove default on cul_reason_id and cul_reason_plaintext_id in the cu_log table to Remove default on cul_reason_id and cul_reason_plaintext_id in the cu_log table on wmf wikis.Feb 4 2023, 2:32 AM
Marostegui triaged this task as Medium priority.
Marostegui moved this task from Triage to Ready on the DBA board.

That cross-referenced ticket should not affect wmf wikis and this task. The summary is:

  • There was a shortly after reverted patch that introduced these columns which had the default as NULL.
  • These columns were only added for wikis that pulled the master branch of CheckUser and then ran update.php between 4th of June 2022 and 6th of June 2022
  • This version of the columns was never added to WMF wikis, and the column on WMF wikis have always been NOT NULL (T321391 added them and the ALTER run defined both columns as BIGINT UNSIGNED DEFAULT 0 NOT NULL)

I have gone into more detail in that task, and will make a fix shortly.

The task has now been resolved, so it should be safe to continue here.

I have ran this on s6 db1187 (for frwiki) and I am going to leave this running for 24h to make sure there are no errors in production.

Mentioned in SAL (#wikimedia-operations) [2023-02-07T14:59:05Z] <marostegui> dbmaint deploy schema change on s6 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-07T15:05:26Z] <marostegui> dbmaint deploy schema change on s8 T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:18:24Z] <marostegui> dbmaint deploy schema change on s8 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:18:46Z] <marostegui> dbmaint deploy schema change on s4 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:19:15Z] <marostegui> dbmaint deploy schema change on s5 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:38:01Z] <marostegui> dbmaint deploy schema change on s2 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:56:31Z] <marostegui> dbmaint deploy schema change on s7 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T07:59:36Z] <marostegui> dbmaint deploy schema change on s1 eqiad (with replication) T328807 T328828

Mentioned in SAL (#wikimedia-operations) [2023-02-08T08:01:58Z] <marostegui> dbmaint deploy schema change on s3 eqiad (with replication) T328807 T328828

Started on s3, will take around 6h

Marostegui updated the task description. (Show Details)

This is done