Multi-user locking

When two users are concurrently modifying an invoice the last user submitting the update wins and his version of the invoice overwrite modifications done in the meantime.

Is it possible to add locking to invoices and generally to editable elements?

Is this such a problem? How often do two users edit the same transaction at the same time?

And yeah I know that sounds unlikely but since this is a multi-user version and this could happen … it will probably happen at some point. You know – Murphy’s law.

Little ping just to know how you feel about that issue?

I just don’t think this is an issue. I’ve seen locking implemented in other systems and it was causing more trouble than actually being useful.

For example… I’m on the phone with customer and I can’t update their phone number. Who is holding the lock to this customer? Josh? Where is Josh? Oh, he is not even at work today. How do I unlock this record so it can be edited? Etc.

Thanks, I see your point.



First of all I would like to say that you built amazing application here. I just installed server edition and trying to set up my accounts, so far only good experience.

Accidentally found this question on multi-user locking and couldn’t help to give some input.

What you described is pessimistic locking strategy, however in web applications it should not be used, for the reasons you described.

All web systems I build we used optimistic timestamp locking strategy, where you don’t need to lock record for editing, but you want to ensure you are checking that you saving same record and not simply discarding valid edits.

It is very easy to reproduce:
user1 opens record
user2 opens same record
user2 saves record
user1 saves record and overrides user2 all edits with old values + edits

If user2 will open record again he will be annoyed because his changes are reverted

What should happen:
user1 opens record
user2 opens same record
user2 saves record
user1 saves record

gets exception saying "Sorry other user updated record, please enter information again."
reload record with user2 edits for user1 to do informed edits

In this way user is made aware of situation and he can do informed edit rather than blind override of potentially important information.

Yes it doesn’t happen very frequently, but when it does it usually very bad.
Substitute user1 and user2 with same user on 2 different tabs and likelihood of situation is very high.
It is very hard to trust application that doesn’t take your data seriously.

If you want examples of implementation I can provide some, but it might be a bit complicated on sqlite, because of its limitations. I do really hope that you have on roadmap to migrate to mysql or similar at least for server edition.

1 Like