mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
(stable) When a large number of commits need to be marked as published, issue the lookup query in chunks
Summary: See PHI1474. This query can become large enough to exceed reasonable packet limits. Chunk the query so it is split up if we have too many identifiers. Test Plan: Ran `bin/repository refs ...` on a repository with no new commits and a repository with some new commits. Differential Revision: https://secure.phabricator.com/D20853
This commit is contained in:
parent
7c83076fb6
commit
ed7d22142a
1 changed files with 23 additions and 9 deletions
|
@ -498,7 +498,7 @@ final class PhabricatorRepositoryRefEngine
|
||||||
private function setCloseFlagOnCommits(array $identifiers) {
|
private function setCloseFlagOnCommits(array $identifiers) {
|
||||||
$repository = $this->getRepository();
|
$repository = $this->getRepository();
|
||||||
$commit_table = new PhabricatorRepositoryCommit();
|
$commit_table = new PhabricatorRepositoryCommit();
|
||||||
$conn_w = $commit_table->establishConnection('w');
|
$conn = $commit_table->establishConnection('w');
|
||||||
|
|
||||||
$vcs = $repository->getVersionControlSystem();
|
$vcs = $repository->getVersionControlSystem();
|
||||||
switch ($vcs) {
|
switch ($vcs) {
|
||||||
|
@ -515,13 +515,27 @@ final class PhabricatorRepositoryRefEngine
|
||||||
throw new Exception(pht("Unknown repository type '%s'!", $vcs));
|
throw new Exception(pht("Unknown repository type '%s'!", $vcs));
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_commits = queryfx_all(
|
$identifier_tokens = array();
|
||||||
$conn_w,
|
foreach ($identifiers as $identifier) {
|
||||||
'SELECT id, phid, commitIdentifier, importStatus FROM %T
|
$identifier_tokens[] = qsprintf(
|
||||||
WHERE repositoryID = %d AND commitIdentifier IN (%Ls)',
|
$conn,
|
||||||
$commit_table->getTableName(),
|
'%s',
|
||||||
$repository->getID(),
|
$identifier);
|
||||||
$identifiers);
|
}
|
||||||
|
|
||||||
|
$all_commits = array();
|
||||||
|
foreach (PhabricatorLiskDAO::chunkSQL($identifier_tokens) as $chunk) {
|
||||||
|
$rows = queryfx_all(
|
||||||
|
$conn,
|
||||||
|
'SELECT id, phid, commitIdentifier, importStatus FROM %T
|
||||||
|
WHERE repositoryID = %d AND commitIdentifier IN (%LQ)',
|
||||||
|
$commit_table->getTableName(),
|
||||||
|
$repository->getID(),
|
||||||
|
$chunk);
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$all_commits[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE;
|
$closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE;
|
||||||
|
|
||||||
|
@ -539,7 +553,7 @@ final class PhabricatorRepositoryRefEngine
|
||||||
|
|
||||||
if (!($row['importStatus'] & $closeable_flag)) {
|
if (!($row['importStatus'] & $closeable_flag)) {
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn_w,
|
$conn,
|
||||||
'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d',
|
'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d',
|
||||||
$commit_table->getTableName(),
|
$commit_table->getTableName(),
|
||||||
$closeable_flag,
|
$closeable_flag,
|
||||||
|
|
Loading…
Reference in a new issue