Page MenuHomePhabricator

babel database doesn't support language codes longer than 10 characters (e.g. de-x-formal)
Open, Needs TriagePublic0 Story Points

Description

Query: REPLACE INTO `bw_babel` (babel_lang,babel_level,babel_user) VALUES ('de-x-formal','N','7408') Function: MediaWiki\Babel\Database::setForUser Error: 1406 Data too long for column 'babel_lang' at row 1 (127.0.0.1:3306)

seen on translatewiki.

-- language code
babel_lang varchar(10) not null,

is the table's schema. Probably we need to make the column larger..

Related Objects

Event Timeline

Legoktm created this task.Jun 25 2019, 5:41 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 25 2019, 5:41 PM

Hi DBA, input requested please :)

When I created the babel database table nearly 3 years ago, the longest code at the time (I believe) was 10 characters or less, so that was how large I made the column...but it's no longer big enough. If we made the column varchar(30), would that be OK?

The longest code right now is nl-x-informal (13 characters). Even though it's deprecated, a theoretical zh-min-nan-x-informal is 21. So I think 30 is a good target for future proofing so we don't need to bump up the size again.

The babel_lang column is part of the primary key and an index.

Here's the complete proposed new schema:

CREATE TABLE /*_*/babel (
        -- user id
        babel_user int UNSIGNED not null,
        -- language code
        --                 vv this is the only change
        babel_lang varchar(30) not null,
        -- level (1-5, N)
        babel_level VARCHAR(2) NOT NULL,

        PRIMARY KEY ( babel_user, babel_lang )
) /*$wgDBTableOptions*/;

-- Query all users who know a language at a specific level
CREATE INDEX /*i*/babel_lang_level ON /*_*/babel (babel_lang, babel_level);

And for reference, here's how big the table is on the large Wikimedia wikis plus meta in case that's helpful: P8656

Is it only on the wikis you pasted, or could it be on more?

If we made the column varchar(30), would that be OK?

Sure, send a code patch for the extension with the concrete alter, timeline and the rest of the data we need, you have a template for the requests here: https://wikitech.wikimedia.org/wiki/Schema_changes#Workflow_of_a_schema_change

Small uncontroversial changes do not require discussion, just the request has to be clear for us to execute it.

Reedy added a subscriber: Reedy.Jun 25 2019, 9:52 PM

Is it only on the wikis you pasted, or could it be on more?

Nope, every wiki should have the table (the extension is enabled everywhere but loginwiki and votewiki)

Marostegui added a subscriber: Marostegui.

Is it only on the wikis you pasted, or could it be on more?

Nope, every wiki should have the table (the extension is enabled everywhere but loginwiki and votewiki)

Let's specify that on the final Blocked-on-schema-change too so it is easier for us to follow :-)
As Jaime said, please use the template at https://wikitech.wikimedia.org/wiki/Schema_changes#Workflow_of_a_schema_change once the code is merged and this is ready to be taken over by DBAs
By the way, the alter needed would be: alter table babel modify babel_lang varbinary(30) NOT NULL;
Removing the DBA tag as it has been answered, please tag us on the final ticket once the schema change is ready to go.

Thanks!