Pessimistic vs Optimistic

Locking that is.

I had a funny situation recently. The funny situation being: moving document from the document management system to the source control system. Nothing special and I understand the reasons. But it got me thinking… Some time ago I would have opted to keep everything in source control. And getting a little maturer I changed this opinion.

Today my opinion is that document should be kept in a document management system and source code in a source control system. Sounds logical. But did you ever ask yourself why this is so? I have today and after thinking about it for some time came to the conclusion that the main difference is the concurrency control.

If you want to read more about concurrency control you can find better sources on the internet. What I would like to stress here is:

  • Source control system use optimistic locking
  • Document management systems use pessimistic locking

Working with source code you do not want to acquire exclusive edit tokens for every file you touch. This would basically make normal work impossible.  You want to do your work and after you are done you take care of all the conflicts.
On the other hand if you are working on a document (word, writer, …), the last thing you want is to find out that someone beat  you to the punch and checked in a newer version of the same document. Resolving the merge conflicts is quite a challenge. In this situation you want to acquire a exclusive edit token for your document.

So why is resolving merge conflicts in document hard and the same thing with source code easy? Thinking about it I come to a weary simple conclusion: Source code is nothing more than text file; documents are big binary files that need special applications to make sense of the zeros and ones.

Taking this into account we have to change our initial categorization of source code and documents to text files and binary files. Going along this line of thought we can put up the following finding:

  • Optimistic locking with text files
  • Pessimistic locking with binary files

This way you can edit all your images, documents and presentations without fear, and the developers can do their stuff efficiently.


3 thoughts on “Pessimistic vs Optimistic

  1. Hi Dejan,

    I agree that documents should be put in DMS and code in VCS, and I also agree on the pessimistic vs. optimisic locking.

    Still, you could do it all in the VCS. A decent VCS allows you to configure the lock type based on the file type or the file location.

    So there must be other reasons, why we prefer the DMS for documents…

    Kind regards,

  2. Hi Dejan!

    I would not simple reduce the reasons for merging problems to text and binary files. But also to the kinf of content.

    Source code is something logical based on standards and rules, where merging can be done systemathically.

    Documents contains mostly prosa and ideas. Therefore it will be hard to merge because you will need the context of the previous changes.

    cbeers, Juergen

    • The example posted is probably not the best one out-there but was the only one that came to mind when writing the post. Maybe I should revisit this topic and try to make a better point.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s