3 ms·
begin transaction; write to db; post /api commit; Assuming rollback is implicit when an exception occurs, failure at any point results in the whole op
by mping 5y ago
begin transaction;
write to db;
post /api
commit;
Assuming rollback is implicit when an exception occurs, failure at any point results in the whole operation not executing.
- cjg 5y agoWhat happens when the REST server accepts your POST to /api and starts processing it but then, before the response can be sent, the connection drops? This code would see an error from the POST to /api due to a connection failure / timeout, and the transaction rolls back. Now you've got the /api invoked, but no DB write.