[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Matthias Klose

New submission from Matthias Klose :

[forwarded from http://bugs.debian.org/451733]

the mailbox._singlefileMailbox class is not safe with concurrent access,
because mailbox._singlefileMailbox.flush() replaces the underlying file
with a new copy by constructing a temporary file and then renaming it.
This breaks all other class instances which have this mailbox open.  I'm
attaching a script demonstrating the problem. 

I think it's a bad idea to use rename(2) here; overwriting the file
content would fix the race condition, and #451274 too[1].

--
components: Library (Lib)
messages: 95487
nosy: doko
severity: normal
status: open
title: [mailbox] race: mbox may lose data with concurrent access
versions: Python 2.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Matthias Klose

Changes by Matthias Klose :


Added file: http://bugs.python.org/file15364/mailbox-race.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> the mailbox._singlefileMailbox class is not safe with concurrent access,
> because mailbox._singlefileMailbox.flush() replaces the underlying file
> with a new copy by constructing a temporary file and then renaming it.
> This breaks all other class instances which have this mailbox open.

I don't think this class aims at being safe against concurrent access,
so having it fail loudly is a good thing.
Besides, the proposed cure (overwriting instead of renaming) looks worse
than the illness. The virtue of renaming is that it is atomic (on POSIX
systems at least), so you can't end up with a half-written mailbox if
there's a crash or an IO problem in the middle.

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Oops, sorry:
> I don't think this class aims at being safe against concurrent access,
> so having it fail loudly is a good thing.

I now understand that the problem is that it doesn't fail loudly. That's
what I get for replying too quickly.
Still, I don't think the suggested fix is ok. Perhaps we should simply
state in the documentation that flush() discards the old file, so that
other processes accessing it may get a surprise.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Actually, the doc is quite clear about it:

« Be very cautious when modifying mailboxes that might be simultaneously
changed by some other process. The safest mailbox format to use for such
tasks is Maildir; try to avoid using single-file formats such as mbox
for concurrent writing. »

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2009-11-19 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +akuchling

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Can this be closed?

--
nosy: +petri.lehtinen

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-18 Thread R. David Murray

R. David Murray  added the comment:

Probably.  Unless I'm mistaken, the issue with concurrent rewrite (as opposed 
to append) exists for single-file-mailboxes in the general case, not just in 
Python.  And as far as I know failure is never noisy, the last writer wins.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-25 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

I created #15122 for adding an option to rewrite the contents of single-file 
mailboxes in-place. Closing this issue as wontfix.

--
resolution:  -> wont fix
stage:  -> committed/rejected
status: open -> closed
superseder:  -> Add an option to always rewrite single-file mailboxes in-place.

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com