Deep runtime internals, memory models, distributed design, concurrency failure modes, and architectural decisions.
get_compiler().as_sql() runs against the vendor backend..order_by() reset or subqueries); aggregates over joins multiply rows; extra() escapes the model entirely.Skeleton:
def transfer(src, dst, amount, idem_key):
if Transfer.objects.filter(idem_key=idem_key).exists(): return existing
try:
with transaction.atomic():
t = Transfer.objects.create(..., status="pending", idem_key=idem_key)
accounts locked via select_for_update; balances adjusted
transaction.on_commit(lambda: queue.enqueue("settle", t.id))
except IntegrityError: return existing # concurrent duplicate
Points: unique idem_key arbitrates concurrency; on_commit guarantees enqueue only post-commit (avoid ghost jobs); worker itself idempotent re-checking state before applying external effects.
USING (tenant_id = current_setting('app.tenant')::uuid)).SET LOCAL app.tenant inside atomic block per request (connection-scoped, pooling caveats with pgbouncer transaction mode → use SET SESSION on dedicated connections).You've completed the 5 free sample questions. Get unrestricted lifetime access to every question, model answer, implementation challenge, and all 27+ technologies for a single payment.
₹399 India / $9 International · One-time settlement · Zero subscription