I have this code sample that should take row (tuple) lock in postgres, however it seems to take table (relation) lock instead:
with transaction.Atomic(savepoint=True, durable=False):
record = MyModel.objects.select_for_update().filter(pk='1234')
record.delete()
time.sleep(5)
raise Exception
By looking at the pg_locks during the time of the transaction I can see:
select locktype, database, relation::regclass, pid, mode, granted from pg_locks where pid <> pg_backend_pid();
To my knowledge, I should have seen "tuple" in the locktype since I'm only locking specific row/s and not the entire table
