Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Latest commit

 

History

History
21 lines (14 loc) · 640 Bytes

managin_database_concurrency_in_django.md

File metadata and controls

21 lines (14 loc) · 640 Bytes

Managing Database Concurrency in Django

Speaker: David Seddon (TODO)

Slides: TODO

Video: TODO

  • Cuncurrent workers can cause issues with things like balances:

    • Worker 1 checks balance then removes funds
    • Worker 2 checks balance then removes funds
    • This can lead to double spending.
  • Postgres's default isolation level is read commited.

    • Writes wait if another transaction is already writing (this uses a readonly lock).
    • select_for_update()delays read until readonly locks are released.
  • Select for update on customer account (not ledger) can prevent double spending (pessimistic locking.)