Inject updated TransitService in real-time updaters #6018
Closed
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.
Summary
Real-time updaters use instances of
TransitService
to look up transit data. Currently these instances are created at construction time.This is problematic since
TransitService
instances maintain a reference to a frozen version of theTimetableSnapshot
that is not updated after construction.As of today this does not cause any issue, since the real-time updaters update directly the collections in
TransitModelIndex
, and theTransitService
looks up data inTransitModelIndex
.However #6007 changes this behavior by storing the real-time updates in indexes in
TimetableSnapshot
, making previous real-time updates invisible from the real-time updaters.Among other regressions, this prevents the
EntityResolver
from identifying already created extra journeys, and leads to the creation of duplicated trips.This PR refactors the real-time updaters so that they use
TransitService
instances that refer to theTimetableSnapshot
buffer, thus giving access to all applied real-time updates (including uncommitted ones).This PR is a prerequisite for #6007
Note: the refactoring consists in:
TransitService
instead of aTransitModel
.UpdaterConfigurator
so that it injects in the updaters aTransitService
that points to the TimetableSnapshot buffer.Note: This design is fragile, since there is no way to guarantee that the
TransitService
that points to the buffer will be used only from the GraphWriter thread (this is however the case in this PR) . Ideally this should be enforced. The fact that theSiriFuzzyTripMatcher
is initialized statically makes things more difficult.Issue
No
Unit tests
Added unit test.
Updated unit tests
Documentation
No