Merge lp:~vila/bzr-svn/525571-minimal-atomic-write-bazaar-conf-files-2.1 into lp:bzr-svn/1.0

Proposed by Vincent Ladeuil
Status: Merged
Merged at revision: 3326
Proposed branch: lp:~vila/bzr-svn/525571-minimal-atomic-write-bazaar-conf-files-2.1
Merge into: lp:bzr-svn/1.0
Diff against target: 42 lines (+10/-6)
2 files modified
NEWS (+3/-0)
config.py (+7/-6)
To merge this branch: bzr merge lp:~vila/bzr-svn/525571-minimal-atomic-write-bazaar-conf-files-2.1
Reviewer Review Type Date Requested Status
bzr-svn developers Pending
Review via email: mp+29439@code.launchpad.net

Commit message

Use atomic writes to protect config files against concurrent writers.

Description of the change

This patch should fix bug #525571 for lp.

https://code.edge.launchpad.net/~vila/bzr/525571-lock-bazaar-conf-files/+merge/28898
won't land soon but https://code.edge.launchpad.net/~vila/bzr/525571-minimal-atomic-write-bazaar-conf-files-2.1/+merge/29086 has already landed for bzr-2.1

The later is a minimal fix but needs to be done too in bzr-svn (which this patch does).

The former is a more correct/robust/whatever solution but lp:bzr-svn@3323 is not enough to use it.
The discussion I had with Jelmer that led to 3323 was based on a flawed design that didn't
require to use @needs_write_lock on set_user_option() methods (the correct design will break the backward compatibility for the 3323 fix :-/).

See the mp discussions mentioned above for the details, but in summary *this* patch:
- mimics the minimal fix landed in bzr-2.1,
- will fix the issue encountered on lp,
- doesn't require deploying a new bzr on lp,
- requires that a new bzr-svn is deployed on lp.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-06-29 17:30:48 +0000
3+++ NEWS 2010-07-08 07:21:42 +0000
4@@ -55,6 +55,9 @@
5 * Cope with concurrent access to ~/.bazaar/subversion.conf.
6 (Vincent Ladeuil, Jelmer Vernooij, #525571)
7
8+ * Concurrent processes don't mix up writes in config files (interim
9+ fix for lp). (Vincent Ladeuil, #525571)
10+
11 FEATURES
12
13 * Support fetching a limited number of revisions. (Michael Hudson)
14
15=== modified file 'config.py'
16--- config.py 2010-06-29 17:30:48 +0000
17+++ config.py 2010-07-08 07:21:42 +0000
18@@ -1,4 +1,4 @@
19-# Copyright (C) 2007-2009 Jelmer Vernooij <jelmer@samba.org>
20+# Copyright (C) 2007-2010 Jelmer Vernooij <jelmer@samba.org>
21
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License as published by
24@@ -107,12 +107,13 @@
25 :param name: Name of the option.
26 :param value: Value of the option.
27 """
28- conf_dir = os.path.dirname(self._get_filename())
29- ensure_config_dir_exists(conf_dir)
30+ file_name = self._get_filename()
31+ ensure_config_dir_exists(os.path.dirname(file_name))
32+ atomic_file = atomicfile.AtomicFile(file_name)
33 self[name] = value
34- f = open(self._get_filename(), 'wb')
35- self._get_parser().write(f)
36- f.close()
37+ self._get_parser().write(atomic_file)
38+ atomic_file.commit()
39+ atomic_file.close()
40
41
42 class SvnRepositoryConfig(Config):

Subscribers

People subscribed via source and target branches