~/talk

Pessimism, optimism, realism and Django database concurrency

Talkat PyCon Italia 2023 · 2023-05-25..05-28· [django, databases]
slides:none on file

Describes concrete fixes for DB concurrency in Django: use SELECT ... FOR UPDATE for pessimistic locking, or an optimistic scheme with a version field and retries; notes Django needs packages for optimistic locking and that using F() expressions makes version increments race-safe because the DB evaluates them under lock. Shows Oracle and Django behaviour where updates and even creates block, cites a real system hitting >5,000 transactions/sec, and recommends finer lock granularity and moving noncritical writes out of the transaction rather than adding Redis locks.

AI-written summary · about

  1. 0:00Introduction and background
  2. 1:09Real-world concurrency challenges
  3. 3:16Race conditions and lost updates
  4. 8:36Shared database concurrency
  5. 10:04Pessimistic locking in Django
  6. 11:07Optimistic locking explained
  7. 12:55Optimistic locking approaches
  8. 14:59Database-level locking behavior
  9. 17:29Performance impact of database locks
  10. 18:54Reducing lock duration
  11. 20:41Optimizing transaction structure
  12. 21:26Version increment mechanics
  13. 23:37Transfer without explicit locks
  14. 24:19Key takeaways and best practices
  15. 25:05Testing concurrency approaches
  16. 26:33Q&A on database blocking
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.