Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'mktime(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'mktime(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CEST/2.0/DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 29.', 2, '', 'http://davidtanzer.net/?q=node/118', '', '54.197.87.25', 1398327784) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Version Control: Why pessimistic locking of source code is a very bad idea

|

When multiple developers work on a single project it is necessary to use software configuration management tools, the minimal requirement here is a version control system. The version control system ensures that the developers can concurrently work on the code without accidentally destroying the work of others. To ensure this there are 2 basic strategies a version control system can support:

  • Lock-Modify-Unlock (LMU) ("Pessimistic Locking"): Before a developer can change a file he/she hast to obtain a lock, and while the file is locked no other developer can change the file. When the work is done the developers unlocks the file to make it available to all others again.
  • Copy-Modify-Merge (CMM) ("Optimistic Locking"): When a developer starts working he/she obtains a copy of the repository (the "working copy"). All work is done in this working copy, and when some junk of work is finished the developer merges his/her changes back into the repository. If some other developer has also changed a file which should be merged back there is a conflict. The version control system will try to solve the conflict, and if it can't do so automatically it will ask the developer to resolve it.

Most version control systems support only one of these strategies, for example Microsoft's "Visual Source Safe" only supports LMU and the "Concurrent Version System" (CVS) supports only CMM. Newer versions of subversion (SVN) support both strategies, and I have already seen cases where this feature has been abused. When working with a version control system which supports both stragegies one has to decide which strategy is best for which parts of the project. Here is MNSHO about this topic:

  • LMU: Should be used only for files where manual conflict resolving is impossible (i.e. binary files, like images, Word documents, ...).
  • CMM: Should be used in all other cases, particularly for all kinds of text files (i.e. source code).

Pessimistic locking of is arguably a bad idea because:

  1. Merging conflicts in text files is a really trivial task. Everybody can do it, and it does not consume very much time.
  2. In a project with a reasonable project plan and good communication between the developers conflicts will occur wery seldom.
  3. LMU can cause sequentialization of tasks which could easily be parallelized, and this can cost a lot of time.
  4. With LMU, if a developer can not check in a file because it still has compile errors and he/she becomes sick, the file might be locked for a long time. This causes trouble for all other developers and the administrators of the version control system.
  5. Locking creates a false sense of security: When a developer locks a file and works on it while another developer works on another file, the system can be broken anyway if the two files depend on each other.

Sources:
Lock-Modify-Unlock v/s Copy-Modify-Merge (Charles Lobo)
Einführung in Subversion (Thorsten Möller, Uni Basel)
Lock-Modify-Unlock or Copy-Modify-Merge (Scott Bellware)

I'd put another restriction

I'd put another restriction on when CMM shall be used over LMU. In my experience, CMM it shouldn't be used for all kinds of text files, but only for those kinds of text files that are user-editable. A good example are the .rc files of Visual Studio that are used to define GUI dialogs. While the file format solely consists of text, parallel modifications and subsequent merging greatly fails in most cases. Tools that help fix such a conflict (besides a text editor) do not exist, making it extremely hard (not completely impossible, but very hard) to resolve conflicts. A similar issue are XML files: editors may (and in practice, do) change the indentation and line-break structure of the file (while keeping the XML structure identical), which can make it pretty hard to resolve conflicts when merging such altered files (although, as far as I know, there is at least one tool that helps find and merge XML files independent of any indentation and line-break issues, and that is the pro version of XML Spy).


Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_sessions'\nquery: INSERT INTO dt_sessions (sid, uid, cache, hostname, session, timestamp) VALUES ('0c5d2bd765ccfacf7f178542094c5971', 0, 0, '54.197.87.25', 'messages|a:1:{s:5:\\"error\\";a:7:{i:0;s:443:\\"strict warning: date(): It is not safe to rely on the system\\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \\'Europe/Berlin\\ in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120