镜像自地址
https://github.com/wikimedia/mediawiki-extensions-GrowthExperiments.git
已同步 2024-06-01 09:50:34 +08:00
fixLinkRecommendationData: Add --force when a production run is needed
Why: fixLinkRecommendationData currently refuses to run in production when --db-table is passed as an argument. This is because the search index is delayed, and it takes hours (if not days) to recognize update commands coming from GrowthExperiments. Unfortunately, when recovering from broken search index scenario (T362367), the only solution for dangling DB records is to drop them all, and deal with possible incorrect removals later (by re-running the script with --search-index). What: Add --force, which bypasses the "unsafe for production" check. I documented it as "use with care", as during normal operation, there is no reason to ever need to force it, and understanding why the check is there is critical to avoid breakages. Patch also updates docstrings, as batching is in fact implemented, and replication lag is checked in commitTransaction(). The script indeed does not handle search index update lag, so it has some risky aspects, but assuming one is aware of the risks (mainly increasing dangling search records, which are more visible and problematic), it is executable in production. Bug: T364341 Change-Id: Ic8c563ce8fc36e67eeeb8a892e8f327f62a7b146
这个提交包含在:
父节点
190557ed3a
当前提交
e192edb942
|
@ -29,9 +29,8 @@ require_once "$IP/maintenance/Maintenance.php";
|
|||
* Aligns link recommendation data in the growthexperiments_link_recommendations table and the
|
||||
* search index. Useful for fixing test setups if the DB or the index gets messed up somehow.
|
||||
*
|
||||
* No attempt is made to handle replication lag, delayed search index updates due to job queue
|
||||
* size or batching, and similar potential race conditions. As such, this script is not appropriate
|
||||
* for production use.
|
||||
* No attempt is made to handle delayed search index updates due to job queue
|
||||
* size. As such, the script is risky for production, and needs to be used with care.
|
||||
*/
|
||||
class FixLinkRecommendationData extends Maintenance {
|
||||
|
||||
|
@ -76,6 +75,7 @@ class FixLinkRecommendationData extends Maintenance {
|
|||
$this->addOption( 'statsd', 'Report the number of fixes (or would-be fixes, '
|
||||
. 'when called with --dry-run) to statsd' );
|
||||
$this->addOption( 'verbose', 'Show debug output.' );
|
||||
$this->addOption( 'force', 'Force the script to run in production (use with care)' );
|
||||
$this->setBatchSize( 100 );
|
||||
}
|
||||
|
||||
|
@ -101,11 +101,13 @@ class FixLinkRecommendationData extends Maintenance {
|
|||
if ( $this->hasOption( 'db-table' )
|
||||
&& !$this->hasOption( 'dry-run' )
|
||||
&& !$growthServices->getGrowthConfig()->get( 'GEDeveloperSetup' )
|
||||
&& !$this->hasOption( 'force' )
|
||||
) {
|
||||
// Adding search index entries is batched in production, and takes hours. This script would delete
|
||||
// the associated DB records in the meantime.
|
||||
$this->fatalError( 'The --db-table option cannot be safely run in production. (If the current '
|
||||
. 'environment is not production, $wgGEDeveloperSetup should be set to true.)' );
|
||||
. 'environment is not production, $wgGEDeveloperSetup should be set to true. If you REALLY '
|
||||
. 'know what you are doing, use --force.)' );
|
||||
}
|
||||
$this->configurationLoader = $growthServices->getNewcomerTasksConfigurationLoader();
|
||||
$this->linkRecommendationStore = $growthServices->getLinkRecommendationStore();
|
||||
|
|
正在加载...
在新工单中引用
屏蔽一个用户