Page MenuHomePhabricator

ipb_range_start and ipb_range_end should be blank for single-IP blocks
Open, MediumPublic

Description

When ipb_range_start and ipb_range_end were introduced in https://static-codereview.wikimedia.org/MediaWiki/11887.html, they were set to an empty string for single-IP blocks. Identifying ranges which contain a given IP requires scanning, so removing single-IP blocks from the part of the index inhabited by range blocks reduced the amount of scanning which needed to occur.

This was accidentally broken in https://static-codereview.wikimedia.org/MediaWiki/17865.html / https://static-codereview.wikimedia.org/MediaWiki/17866.html, where a call to wfRangeStartEnd(), which rejected single IPs, was replaced with IP::parseRange(), which accepts single IPs.

We now have about 80,000 single-IP blocks on en.wp. 13,000 of them still have an empty ipb_range_start, presumably created before https://static-codereview.wikimedia.org/MediaWiki/17866.html (all have infinite expiry). The amount of table scanning is proportional to the number of blocks in the user's /16 range: 18 /16 ranges have more than 500 blocks, 61 have more than 100 blocks. The problem may well get worse as IPv6 becomes more common: the IPv6 code also uses a /16 division of index space.

ApiQueryBlocks now depends on the fact that ipb_range_start is populated, and so won't correctly display the 13,000 old blocks. Possibly there is other code that makes the same assumption. Such code should be fixed.


Version: 1.22.0
Severity: normal

Related Objects

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:44 AM
bzimport set Reference to bz49504.

Related URL: https://gerrit.wikimedia.org/r/68310 (Gerrit Change Ie229e84b299c357cfe9a2db0a5ba07713aac7597)

https://gerrit.wikimedia.org/r/68310 (Gerrit Change Ie229e84b299c357cfe9a2db0a5ba07713aac7597) | change APPROVED and MERGED [by jenkins-bot]

Change 420618 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Make ipb_range_start and ipb_range_end blank for single-IP blocks

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

Also, looking at https://gerrit.wikimedia.org/r/420618 made me realize that a block of an IP and a block of a range containing just one IP (/32 for IPv4, /128 for IPv6) are currently considered separate blocks. That's... weird. And the latter still needs to fill in ipb_range_start and ipb_range_end, or else it won't block anything.

Unless, of course, we first clean up ipb_address for all the exiting one-IP range blocks to make them be non-range IP blocks.

Possibly there is other code that makes the same assumption.

I wonder how many tools on Toolforge are doing it.

Thank you very much for the quick review @Anomie 🙂 I have amended the patch set according to your notes.

Should I fix the issue with the single IP range blocks in this task or is that out of scope?

Change 971343 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Support new block schema

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

Change 971343 merged by jenkins-bot:

[mediawiki/core@master] Support new block schema

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