mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Fix an issue where repository message counts would never reset
Summary: Fixes T11705. I did not realize that `ON DUPLICATE KEY UPDATE` was order-dependent, so the "reset" clause of this `IF(...)` never actually worked. Reorder it so we check if we're changing the message type //first//, then actually change the message type. This makes the count reset properly when a failing repository succeeds, or a working repository fails. Test Plan: - On `master`, forced a working repository to fail a `bin/repository update`, saw the message change types (expected) but keep the old count (wrong!). - With this patch, repeated the process and saw the count reset properly. - Ran the patch, verified counts reset to 0. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11705 Differential Revision: https://secure.phabricator.com/D16623
This commit is contained in:
parent
360597d8ee
commit
5d1359d78f
2 changed files with 15 additions and 7 deletions
4
resources/sql/autopatches/20160928.repo.messagecount.sql
Normal file
4
resources/sql/autopatches/20160928.repo.messagecount.sql
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* Reset message counts to fix the bug in T11705 which caused some of them to
|
||||
become very large. */
|
||||
UPDATE {$NAMESPACE}_repository.repository_statusmessage
|
||||
SET messageCount = 0;
|
|
@ -1651,8 +1651,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
} else {
|
||||
// If the existing message has the same code (e.g., we just hit an
|
||||
// error and also previously hit an error) we increment the message
|
||||
// count by 1. This allows us to determine how many times in a row
|
||||
// we've run into an error.
|
||||
// count. This allows us to determine how many times in a row we've
|
||||
// run into an error.
|
||||
|
||||
// NOTE: The assignments in "ON DUPLICATE KEY UPDATE" are evaluated
|
||||
// in order, so the "messageCount" assignment must occur before the
|
||||
// "statusCode" assignment. See T11705.
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
|
@ -1661,14 +1665,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
messageCount)
|
||||
VALUES (%d, %s, %s, %s, %d, %d)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
statusCode = VALUES(statusCode),
|
||||
parameters = VALUES(parameters),
|
||||
epoch = VALUES(epoch),
|
||||
messageCount =
|
||||
IF(
|
||||
statusCode = VALUES(statusCode),
|
||||
messageCount + 1,
|
||||
VALUES(messageCount))',
|
||||
messageCount + VALUES(messageCount),
|
||||
VALUES(messageCount)),
|
||||
statusCode = VALUES(statusCode),
|
||||
parameters = VALUES(parameters),
|
||||
epoch = VALUES(epoch)',
|
||||
$table_name,
|
||||
$this->getID(),
|
||||
$status_type,
|
||||
|
|
Loading…
Reference in a new issue