OpenRailAssociation / osrd

An open source web application for railway infrastructure design, capacity analysis, timetabling and simulation
https://osrd.fr
GNU Lesser General Public License v3.0
419 stars 40 forks source link

Fix infra clone handle search tables #7853

Closed flomonster closed 2 weeks ago

flomonster commented 2 weeks ago

What is done

[!IMPORTANT] We have a minor drawback. While an infra is cloned we take a full lock on track, signal and op tables. This temporarily blocks several types of operation.

Profiling

[!NOTE] Time wasted duplicating forgotten layers is regained by deactivating triggers.

Before

TOTAL: 19s

After

TOTAL: 19s

New:

codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 28.54%. Comparing base (9f12cd4) to head (5815ab3).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #7853 +/- ## ========================================= Coverage 28.54% 28.54% Complexity 2059 2059 ========================================= Files 1249 1249 Lines 154170 154190 +20 Branches 3039 3039 ========================================= + Hits 44006 44014 +8 - Misses 108351 108363 +12 Partials 1813 1813 ``` | [Flag](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [core](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `74.95% <ø> (ø)` | | | [editoast](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `71.66% <100.00%> (-0.03%)` | :arrow_down: | | [front](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `10.01% <ø> (ø)` | | | [gateway](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `2.34% <ø> (ø)` | | | [railjson_generator](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `87.49% <ø> (ø)` | | | [tests](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7853/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `72.93% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

leovalais commented 2 weeks ago

LGTM

Why did you drop try_join_all ? Is it incompatible with the transaction ?

A transaction can only apply to a single connection. Besides, the new testing utils makes it harder to test functions that open multiple connections. And an endpoint opening multiple connections can starve others.

I guess it's one of these reasons ¯_(ツ)_/¯

flomonster commented 2 weeks ago

LGTM Why did you drop try_join_all ? Is it incompatible with the transaction ?

A transaction can only apply to a single connection. Besides, the new testing utils makes it harder to test functions that open multiple connections. And an endpoint opening multiple connections can starve others.

I guess it's one of these reasons ¯(ツ)

In addition, there was a comment with the try_join_all:

When creating a connection for each objet, it will a panic with 'Cannot access shared transaction state' in the database pool Just one connection fixes it, but partially* defeats the purpose of joining all the requests at the end

  • AsyncPgConnection supports pipeling within one connection, but it won’t run parallel