From 8b715a64b52dd90668a1e422c159b49e0d31af6f Mon Sep 17 00:00:00 2001 From: vrana Date: Mon, 27 Aug 2012 13:08:58 -0700 Subject: [PATCH] Don't waste too much cache by a single changeset Summary: We have `max_allowed_packet` 1 GiB but our replication dies if the query is longer than unknown value (it dies with 293 MB long query). Anyway, there's no reason why we should not save the cache if you have small `max_allowed_packet`. Test Plan: Lowered `$size` to 100, deleted cache from DB, displayed changeset, verified issued queries in DarkConsole, verified DB. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3390 --- .../differential/parser/DifferentialChangesetParser.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index 646e1b65b1..35f6cef856 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -61,6 +61,7 @@ final class DifferentialChangesetParser { private $highlightErrors; const CACHE_VERSION = 6; + const CACHE_MAX_SIZE = 8e6; const ATTR_GENERATED = 'attr:generated'; const ATTR_DELETED = 'attr:deleted'; @@ -746,6 +747,11 @@ final class DifferentialChangesetParser { } $cache = json_encode($cache); + // We don't want to waste too much space by a single changeset. + if (strlen($cache) > self::CACHE_MAX_SIZE) { + return; + } + try { $changeset = new DifferentialChangeset(); $conn_w = $changeset->establishConnection('w');