Skip to content

Commit 7124835

Browse files
committed
No long transactions!
If you intend to deactivate someone, and the process fails mid process, so you only delete some sessions, or some accesses, you are actually fine. The system is never left in an incomplete state. And that's really the only time we should be using transactions with sqlite3 -- to prevent actual data integrity issues. The rest of the time, we should optimize for each transaction to be as quick as possible. The sqlite3 writer lock is the one bottleneck that we cant afford to overload.
1 parent 90f05b7 commit 7124835

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/models/user.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ def initials
2424
end
2525

2626
def deactivate
27-
transaction do
28-
sessions.delete_all
29-
accesses.destroy_all
30-
update! active: false, email_address: deactived_email_address
31-
end
27+
sessions.delete_all
28+
accesses.destroy_all
29+
update! active: false, email_address: deactived_email_address
3230
end
3331

3432
private

0 commit comments

Comments
 (0)