From aeeef1d6085b342fd37d9bc25a66fb74172247b7 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Thu, 4 Oct 2018 13:34:48 -0700 Subject: [PATCH 1/2] Fix infinite loop on corrupted fine-grained cache This hit me when mypyc was causing crashes after having written out part of the cache, but subsequent runs would instead infinite loop. --- mypy/build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mypy/build.py b/mypy/build.py index 12c17cfc2b0be..609deb77f274c 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2145,6 +2145,8 @@ def dispatch(sources: List[BuildSource], manager: BuildManager) -> Graph: if proto_deps is not None: TypeState.proto_deps = proto_deps elif manager.stats.get('fresh_metas', 0) > 0: + # Clear the stats so we don't infinite loop because of positive fresh_metas + manager.stats.clear() # There were some cache files read, but no protocol dependencies loaded. manager.log("Error reading protocol dependencies cache -- aborting cache load") manager.cache_enabled = False From 180e516a402af4f19fd7757c98ffe12b539ff4dd Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Fri, 5 Oct 2018 11:03:40 -0700 Subject: [PATCH 2/2] Add a test --- test-data/unit/check-incremental.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 563fa80b2e942..c84f61bfe82ac 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -4350,6 +4350,21 @@ import b [stale a, b, builtins] [rechecked a, b, builtins] +[case testIncrementalBustedFineGrainedCache3] +# flags: --cache-fine-grained +import a +import b +[file a.py] +[file b.py] +-- This is a heinous hack, but we simulate having a invalid cache by deleting +-- the proto deps file. +[delete ../.mypy_cache/3.6/@proto_deps.meta.json.2] +[file b.py.2] +# uh +-- Every file should get reloaded, since the cache was invalidated +[stale a, b, builtins] +[rechecked a, b, builtins] + [case testIncrementalWorkingFineGrainedCache] # flags: --cache-fine-grained # flags2: --cache-fine-grained