Skip to content

Commit

Permalink
Merge pull request #89 from epandurski/master
Browse files Browse the repository at this point in the history
Use with_for_update(key_share=True)
  • Loading branch information
epandurski authored Aug 14, 2024
2 parents 9921d98 + 72c6ef8 commit 58f7a10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions swpt_debtors/procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_debtor(
== Debtor.STATUS_IS_ACTIVATED_FLAG
)
if lock:
query = query.with_for_update()
query = query.with_for_update(key_share=True)

return query.one_or_none()

Expand Down Expand Up @@ -213,7 +213,7 @@ def update_debtor_config(

@atomic
def get_debtor_transfer_uuids(debtor_id: int) -> List[UUID]:
debtor = get_active_debtor(debtor_id, lock=True)
debtor = get_active_debtor(debtor_id)
if debtor is None:
raise DebtorDoesNotExist()

Expand All @@ -234,7 +234,7 @@ def get_running_transfer(
debtor_id=debtor_id, transfer_uuid=transfer_uuid
)
if lock:
query = query.with_for_update()
query = query.with_for_update(key_share=True)

return query.one_or_none()

Expand Down Expand Up @@ -353,7 +353,7 @@ def process_rejected_config_signal(
func.abs(Debtor.min_balance + negligible_amount)
<= EPS * negligible_amount
)
.with_for_update()
.with_for_update(key_share=True)
.one_or_none()
)

Expand All @@ -374,7 +374,7 @@ def process_account_purge_signal(
has_server_account=True,
)
.filter(Debtor.account_creation_date <= creation_date)
.with_for_update()
.with_for_update(key_share=True)
.one_or_none()
)

Expand Down
2 changes: 1 addition & 1 deletion swpt_debtors/table_scanners.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def has_unreported_config_problem(row) -> bool:
Debtor.status_flags.op("&")(status_flags_mask)
== Debtor.STATUS_IS_ACTIVATED_FLAG
)
.with_for_update(skip_locked=True)
.with_for_update(skip_locked=True, key_share=True)
.all()
)

Expand Down

0 comments on commit 58f7a10

Please sign in to comment.