News for hackers. Stuff that matters.
Re:Scaling Databases at Activision [pdf] by drwiggly on Saturday April 22, 2023 @04:48PM (#35670784)
start transaction;

select id from users where id = ? for update;

if row_count() < 1 then raise 'no user' end if;

insert into sub_resource (owner, thing) values (?, ?);

commit;

??

Re:Scaling Databases at Activision [pdf] by AlisdairO on Saturday April 22, 2023 @06:40PM (#35671559)
Do that in most relational dbs in the default isolation level (read committed), and concurrently executing transactions will still be able to delete users underneath you after the select.

If we take postgres as an example, performing the select takes exactly zero row level locks, and makes no guarantees at all about selected data remaining the same after you’ve read it.