Use write connection and transactions in SQL patches
Summary: Patches often read from slaves (possibly stale data) and use that information to write on master. It causes problems when applying more patches quickly after each other because data created in previous patch may not be replicated yet. Test Plan: $ bin/storage upgrade Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4483
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
$table = new DifferentialRevision();
|
||||
$table->openTransaction();
|
||||
$table->beginReadLocking();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
echo "Migrating revisions";
|
||||
do {
|
||||
$revisions = id(new DifferentialRevision())
|
||||
->loadAllWhere('branchName IS NULL LIMIT 1000');
|
||||
$revisions = $table->loadAllWhere('branchName IS NULL LIMIT 1000');
|
||||
|
||||
foreach ($revisions as $revision) {
|
||||
echo ".";
|
||||
@@ -28,4 +29,7 @@ do {
|
||||
$revision->getID());
|
||||
}
|
||||
} while (count($revisions) == 1000);
|
||||
|
||||
$table->endReadLocking();
|
||||
$table->saveTransaction();
|
||||
echo "\nDone.\n";
|
||||
|
||||
Reference in New Issue
Block a user