Re:Scaling Databases at Activision [pdf]
by edf13 on Saturday April 22, 2023 @02:40AM
(#35663979)
Add your user check as a where clause on the resources insert?
[ Parent
| on HN ]
Re:Scaling Databases at Activision [pdf]
by AlisdairO on Saturday April 22, 2023 @10:47AM
(#35667087)
Can you give an example? I’m not aware of a mechanism like that that will protect you from concurrency artifacts reliably - certainly not a general one.
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.