Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject updated TransitService in real-time updaters #6018

Closed

Conversation

vpaturet
Copy link
Contributor

@vpaturet vpaturet commented Aug 23, 2024

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 the TimetableSnapshot 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 the TransitService looks up data in TransitModelIndex.

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 the TimetableSnapshot 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:

  • Modifying the constructors of the real-time updaters so that they accept a TransitService instead of a TransitModel.
  • Modifying UpdaterConfigurator so that it injects in the updaters a TransitService 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 the SiriFuzzyTripMatcher is initialized statically makes things more difficult.

Issue

No

Unit tests

Added unit test.
Updated unit tests

Documentation

No

@vpaturet vpaturet added Technical Debt Real-Time Update The issue/PR is related to RealTime updates Skip Changelog labels Aug 23, 2024
@vpaturet vpaturet self-assigned this Aug 23, 2024
@vpaturet vpaturet marked this pull request as ready for review August 23, 2024 16:45
@vpaturet vpaturet requested a review from a team as a code owner August 23, 2024 16:45
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 8.82353% with 31 lines in your changes missing coverage. Please review.

Project coverage is 69.73%. Comparing base (8164d41) to head (642272a).
Report is 29 commits behind head on dev-2.x.

Files Patch % Lines
...planner/updater/configure/UpdaterConfigurator.java 0.00% 18 Missing ⚠️
...pentripplanner/ext/siri/updater/SiriSXUpdater.java 0.00% 2 Missing ⚠️
...ner/ext/siri/updater/azure/SiriAzureSXUpdater.java 0.00% 2 Missing ⚠️
...anner/updater/alert/GtfsRealtimeAlertsUpdater.java 0.00% 2 Missing ⚠️
...t/siri/updater/azure/AbstractAzureSiriUpdater.java 0.00% 1 Missing ⚠️
...ner/ext/siri/updater/azure/SiriAzureETUpdater.java 0.00% 1 Missing ⚠️
...pplanner/routing/impl/TransitAlertServiceImpl.java 75.00% 0 Missing and 1 partial ⚠️
...pplanner/updater/trip/MqttGtfsRealtimeUpdater.java 0.00% 1 Missing ⚠️
...entripplanner/updater/trip/PollingTripUpdater.java 0.00% 1 Missing ⚠️
...pplanner/updater/trip/TimetableSnapshotSource.java 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6018      +/-   ##
=============================================
- Coverage      69.73%   69.73%   -0.01%     
- Complexity     17314    17318       +4     
=============================================
  Files           1960     1960              
  Lines          74267    74274       +7     
  Branches        7603     7603              
=============================================
+ Hits           51793    51795       +2     
- Misses         19831    19839       +8     
+ Partials        2643     2640       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vpaturet vpaturet added the Entur Test This is currently being tested at Entur label Aug 24, 2024
@vpaturet vpaturet marked this pull request as draft August 28, 2024 09:17
@vpaturet
Copy link
Contributor Author

Moved back to draft and attempting to provide a better implementation

@vpaturet
Copy link
Contributor Author

Superseded by #6029

@vpaturet vpaturet closed this Aug 28, 2024
@t2gran t2gran added this to the Rejected milestone Aug 28, 2024
@t2gran t2gran deleted the inject_updated_transit_service branch August 28, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Entur Test This is currently being tested at Entur Real-Time Update The issue/PR is related to RealTime updates Skip Changelog Technical Debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants