70
|
|
|
Kalail |
|
8 years ago
|
|
|
69
|
|
|
Kalail |
|
8 years ago
|
|
|
68
|
|
|
David Cramer |
1.4.1 |
11 years ago
|
|
|
67
|
|
|
Jeff Pollard |
1.4.0 |
11 years ago
|
|
|
66
|
|
|
Jeff Pollard |
|
11 years ago
|
|
|
65
|
|
Fix bug that caused us to pull down things every time
Summary: So there was a bug in modeldict that caused the entire switch set to be pulled from cache any time `_cleanup()` was called on the modeldict, which happened every time the `request_finished` and `task_postrun` signals were fired. This was bad, as it means we have a cache `get()` calls to pull down the heavy switch set every single page load and celery task.
The bug happened because `_cleanup()` reset the `_last_checked_for_remote_changes` variable to `None`, effectively clobbering any information that the modeldict had to know what it's own personal `last_modified` timestamp was. Thus, it had no way to know if the remote cache had changed given its version.
Practically, it caused this line of code to be run:
``` return int(cache_last_updated) > self._last_checked_for_remote_changes ```
`cache_last_updated` was the timestamp of the `last_updated` value in remote cache (when the switch set last changed), and `self._last_checked_for_remote_changes` was `None`, reset by `_cleanup()`. No matter what valid `cache_last_updated` value there is, comparing `any_value > None` is always `True`, so the modeldict thought that remote had changes and it pulled them down.
The change was to add a separate `_local_last_updated` instance variable that actually tracked the cached `last_updated` value. This leaves `_last_checked_for_remote_changes` to only be used to track when the modeldict last synced its local cache with the remote one, and to be reset without blowing away the locally cached `last_updated` value.
Test Plan: Existing tests, plus I added another test that asserts when cleanup is called it does not `get()` the whole switch set from the cache.
Reviewers: dcramer, ted
Reviewed By: dcramer
Differential Revision: http://phabricator.local.disqus.net/D4150
|
Jeff Pollard |
|
11 years ago
|
|
|
64
|
|
|
Jeff Pollard |
|
11 years ago
|
|
|
63
|
|
|
Jeff Pollard |
|
11 years ago
|
|
|
62
|
|
|
David Cramer |
1.3.6 |
11 years ago
|
|
|
61
|
|
|
David Cramer |
|
11 years ago
|
|
|
60
|
|
|
David Cramer |
|
11 years ago
|
|
|
59
|
|
|
David Cramer |
|
11 years ago
|
|
|
58
|
|
|
David Cramer |
|
11 years ago
|
|
|
57
|
|
|
David Cramer |
|
11 years ago
|
|
|
56
|
|
|
David Cramer |
|
11 years ago
|
|
|
55
|
|
|
David Cramer |
|
11 years ago
|
|
|
54
|
|
|
David Cramer |
|
11 years ago
|
|
|
53
|
|
|
David Cramer |
|
11 years ago
|
|
|
52
|
|
|
David Cramer |
1.3.5 |
11 years ago
|
|
|
51
|
|
|
David Cramer |
1.3.4 |
11 years ago
|
|
|