mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
960c447aab
commit
6d74736a7e
1 changed files with 23 additions and 9 deletions
|
@ -498,7 +498,7 @@ final class PhabricatorRepositoryRefEngine
|
|||
private function setCloseFlagOnCommits(array $identifiers) {
|
||||
$repository = $this->getRepository();
|
||||
$commit_table = new PhabricatorRepositoryCommit();
|
||||
$conn_w = $commit_table->establishConnection('w');
|
||||
$conn = $commit_table->establishConnection('w');
|
||||
|
||||
$vcs = $repository->getVersionControlSystem();
|
||||
switch ($vcs) {
|
||||
|
@ -515,13 +515,27 @@ final class PhabricatorRepositoryRefEngine
|
|||
throw new Exception(pht("Unknown repository type '%s'!", $vcs));
|
||||
}
|
||||
|
||||
$all_commits = queryfx_all(
|
||||
$conn_w,
|
||||
'SELECT id, phid, commitIdentifier, importStatus FROM %T
|
||||
WHERE repositoryID = %d AND commitIdentifier IN (%Ls)',
|
||||
$commit_table->getTableName(),
|
||||
$repository->getID(),
|
||||
$identifiers);
|
||||
$identifier_tokens = array();
|
||||
foreach ($identifiers as $identifier) {
|
||||
$identifier_tokens[] = qsprintf(
|
||||
$conn,
|
||||
'%s',
|
||||
$identifier);
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
|
@ -539,7 +553,7 @@ final class PhabricatorRepositoryRefEngine
|
|||
|
||||
if (!($row['importStatus'] & $closeable_flag)) {
|
||||
queryfx(
|
||||
$conn_w,
|
||||
$conn,
|
||||
'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d',
|
||||
$commit_table->getTableName(),
|
||||
$closeable_flag,
|
||||
|
|
Loading…
Reference in a new issue