Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why avoid pessimistic locking in a version control system?

Based on a few posts I've read concerning version control, it seems people think pessimistic locking in a version control system is a bad thing. Why? I understand that it prevents one developer from submitting a change while another has the file checked out, but so what? If your code files are so big that you constantly have more than one person working on them at the same time, I submit that you should reorganize your code. Break it up into smaller functional units.

Integration of concurrent code changes is a tedious and error-prone process even with the tools a good version control system provides to make it easier. I think it should be avoided if at all possible. So, why is pessimistic locking discouraged?

like image 205
raven Avatar asked Sep 26 '08 16:09

raven


2 Answers

  1. Go play with Source Safe and have a developer leave for a two week vacation. Add to that the VSS admins not being around. Now you have a fix to be posted but you can't because of the developer
  2. If you have multiple features and/or bug fixes being worked on. No matter how small your code is broken up, you will still have contention for a central file.
like image 163
Scott Bevington Avatar answered Oct 23 '22 10:10

Scott Bevington


It depends on your project and team generally. Pessimistic locking is good because it is easy to understand - one dev at a time, and no merging required!

However, the bad thing about is is exactly that - one dev at a time. I have the situation right now where a colleague has gone on-site, and before he left, he checked everything out so that if he had to fix any bugs, he could return and check all his changes in.... great for him, lousy for me and the rest of the dev team at base.

If you can get around pessimistic locking in your team then its fine to use it, really, the biggest reason people hate it is because its Visual SourceSafe's default practice. If you're not confident in merging lots of changes, then you have another reason to use it - if you've ever used a optimistic locking SCM, and cocked up a merge, you'll know how hard it is to recover.

If you can handle merging, then optimistic locking is superior and I'd recommend it, but you don't have to hand your geek card in if you don't want to use it.

like image 20
gbjbaanb Avatar answered Oct 23 '22 10:10

gbjbaanb