Skip to content

Commit

Permalink
Merge too finely divided transactions
Browse files Browse the repository at this point in the history
These `with` blocks created two transactions inside functions which
where wrapped in retrying error handlers. This could potentially lead to
always failing retries because committed transactions can not be rolled
back, so errors in the second transactions trigger retries on
unchangeable state. In order to prevent this, it's best to have the
whole function be one transaction.
  • Loading branch information
gnn committed Nov 10, 2022
1 parent d4faeab commit 1f4dbc3
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ def write_link(scenario_name: str) -> None:
terrain_factor=1,
)
)
with db.session_scope() as session:
session.add(
EgonPfHvLinkTimeseries(
scn_name=scenario_name,
Expand Down Expand Up @@ -672,7 +671,6 @@ def write_store(scenario_name: str) -> None:
standing_loss=0,
)
)
with db.session_scope() as session:
session.add(
EgonPfHvStoreTimeseries(
scn_name=scenario_name,
Expand All @@ -699,7 +697,6 @@ def write_load(
sign=-1,
)
)
with db.session_scope() as session:
session.add(
EgonPfHvLoadTimeseries(
scn_name=scenario_name,
Expand Down

0 comments on commit 1f4dbc3

Please sign in to comment.