diff --git a/resources/sql/autopatches/20160928.repo.messagecount.sql b/resources/sql/autopatches/20160928.repo.messagecount.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20160928.repo.messagecount.sql @@ -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; diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -1651,8 +1651,12 @@ } 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 @@ 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,