fix: Don't use a hash function for cache keys #2912
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scope
Asana Ticket: 76 showing Quincy Center trip
The bug manifests non-deterministically, and in both directions - the 76 to Lincoln Labl sometimes shows a Quincy Center trip, and the 210 to Quincy Center sometimes shows the Lincoln Lab trip.
Implementation
The bug is due to a hash collision in the keys that the cache is using to store trips.
We fixed a similar issue in April, but only when
argsis a single-element array. Trip-lookup happens by way of a helper API call function (which is usually given a default value ofMBTA.Api.Trips.by_id/2), so the special-case implemented in #2487 didn't work for trips.Screenshots
How to test
To see the bug locally, visit Schedule Finder for the 201, and then visit Schedule Finder for the 76. The first visit will seed the collided cache for that trip with the 210 trip to Quincy Center, so when you scroll down on the 76 page to around 3:30PM, you'll see
Quincy Centeramid a sea ofLincoln Lab via Hanscom Airport's.You can do the same in the opposite direction by visiting the 76 first and then the 201, but you may have to clear your cache first (
Dotcom.Cache.Multilevel.flush()into aniex -S mixshell).