icaruseu / mom-ca

Monasterium.net (http://www.monasterium.net/mom) - repository and collaborative archive
https://github.com/icaruseu/mom-ca/wiki
GNU General Public License v3.0
17 stars 11 forks source link

locking mechanism for shared documents #64

Open GVogeler opened 9 years ago

GVogeler commented 9 years ago

If one user has loaded the shared document in an editor it should be locked for other users: e.g.:

StephanMa commented 9 years ago

What should happen if the Document is still locked? Should an i18n-Message appear and inform the user about it or should the input-fields are be marked as read-only?

This Issue isn't easy to solve because of the following points:

1) Before the Document is opened, it must be checked if the Charter is still locked. But at this point, the Charter as a document is already loaded! So it is not possible to perform a Statuscheck on document.load etc.... 2) It should be checked seperately before the editor is shown by the Form. If the Charter is still locked within a session timespan (?), the user should get an Information about that. 3) If the Charter is not locked, write the Lock-Node into the Charter-document. 4) Release Charter after leaving the Editor.

GVogeler commented 9 years ago

The user should receive a "Document currently in use by xy"-i18n message instead of the editmom3. we certainly have to do the check as early as possible:If we store the lock in the xml we could even create a service which issue tested before the document is loaded,couldn't we? A major issue is releasing the document with a document.onUnload event can be interrupted by loosing connectivity: possible Evolution might be to consider documents "in use" automatically as release after a defined time span (e.g. a working day of 8 h) 

gioele commented 9 years ago

Locking is hard and there are plenty of pitfalls:

If a lock has an expiration time, it is no longer a normal lock, but a lease: https://books.google.de/books?id=L-LXO9Rkj54C&lpg=PA3&ots=tBus_-U6Qb&dq=lock%20time%20process%20lease&pg=PA3#v=onepage&q=lock%20time%20process%20lease&f=false

All the aforementioned concepts require the presence of a kernel/supervisor (a process that runs in background, never crashes, knows about every running process). If there is no such process, then you are in the domain of distributed consensus ("who holds the lock?") https://en.wikipedia.org/wiki/Paxos_%28computer_science%29

StephanMa commented 9 years ago

Scheduled for a later release and some further investigations