Page MenuHomePhabricator

api.php?format=json (FormatJson.php) Allowed memory size fatal error in quibble-vendor-mysql-php74-selenium-docker
Open, LowPublic

Description

When working to merge this gerrit change set, I'm receiving an error from quibble-vendor-mysql-php74-selenium-docker (which ran fine prior to the merge attempt):

mw-error.log:2023-12-07 16:20:20 c746864ca256 wikidb: [8aa5796020942920599799ff] /api.php?format=json   PHP Fatal Error from line 149 of /workspace/src/includes/json/FormatJson.php: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)

This... seems unrelated to the change set, but it keeps failing and I'm not seeing any other bugs reported in Phabricator, so I guess I'm not sure if ext:StopForumSpam and related tests are the cause.

Event Timeline

The corresponding error in the test is:

[0-1] Error in "Special:RecentChanges.shows page creation"
Error: invalidjson: No valid JSON response
    at /workspace/src/node_modules/mwbot/src/index.js:254:31
    at tryCatcher (/workspace/src/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/workspace/src/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/workspace/src/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/workspace/src/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/workspace/src/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/workspace/src/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/workspace/src/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/workspace/src/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/workspace/src/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:466:21)

When searching for ApiQueryRecentChanges::run in the logs there is one entry, but that does not indicate failures why the json would be big.

Well, this does appear to be related to SFS's default IP list file potentially being too large for Gerrit CI to handle, see: this comment on the change set and T326871. I thought we had already bumped this down once, but maybe that wasn't good enough. If it tests fine again after my commit msg update, I'll resolve this bug.

sbassett closed this task as Resolved.EditedDec 11 2023, 6:39 PM
sbassett claimed this task.
sbassett triaged this task as Low priority.
sbassett moved this task from Untriaged to Done on the Continuous-Integration-Infrastructure board.

...and my assumption above seems to be correct.

hashar subscribed.

Note that the test suite / CI should most probably not fetch SFSIPListLocation ( https://www.stopforumspam.com/downloads/listed_ip_1_ipv46_all.gz ) to prevent hammering the remote. The file can be saved in the CI cache by writing it somewhere under the directory pointed by the environment variable XDG_CACHE_HOME. The previous files, if any, would need to be removed since the cache is rarely cleaned up and files simply accumulate there :)

Note that the test suite / CI should most probably not fetch SFSIPListLocation ( https://www.stopforumspam.com/downloads/listed_ip_1_ipv46_all.gz ) to prevent hammering the remote. The file can be saved in the CI cache by writing it somewhere under the directory pointed by the environment variable XDG_CACHE_HOME. The previous files, if any, would need to be removed since the cache is rarely cleaned up and files simply accumulate there :)

To make it even simpler, we could probably set the default value of SFSIPListLocation to tests/phpunit/sample_denylist_all.txt within the same repo. That will keep the file size / IP data (very) small and we wouldn't have to worry about external http calls or working within the constraints of quibble's caching layers for CI tests. My only concern with this approach is that the extension wouldn't really work out of the box. Not a big deal, I suppose, and we can update the extension doc to state that it is mandatory that users configure SFSIPListLocation before the extension will work properly.

Change 982866 had a related patch set uploaded (by SBassett; author: SBassett):

[mediawiki/extensions/StopForumSpam@master] Add new default SFSIPListLocation value

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

@hashar - So php's is_file() seems to fail (here in ext:SFS) when the quibble tests run when I set SFSIPListLocation to any kind of relative file path, which is what I'd want to set as the default within extension.json. When I set it to the full workspace path, the quibble tests run fine. Any experience with issues like this? Hacky as it might be, is there a similar environment variable to MW_PHPUNIT_TEST, where we could add some quibble-friendly logic that sets SFSIPListLocation to the full workspace file path?