This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年11月19日 16:20 by doko, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| mailbox-race.py | doko, 2009年11月19日 16:20 | test case | ||
| Messages (7) | |||
|---|---|---|---|
| msg95487 - (view) | Author: Matthias Klose (doko) * (Python committer) | Date: 2009年11月19日 16:20 | |
[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]. |
|||
| msg95491 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年11月19日 16:52 | |
> 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. |
|||
| msg95494 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年11月19日 17:06 | |
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. |
|||
| msg95496 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年11月19日 17:18 | |
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. » |
|||
| msg163109 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2012年06月18日 17:40 | |
Can this be closed? |
|||
| msg163111 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年06月18日 18:19 | |
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. |
|||
| msg164048 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2012年06月26日 06:38 | |
I created #15122 for adding an option to rewrite the contents of single-file mailboxes in-place. Closing this issue as wontfix. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:54 | admin | set | github: 51609 |
| 2012年06月26日 06:39:01 | petri.lehtinen | set | status: open -> closed superseder: Always rewrite single-file mailboxes in-place messages: + msg164048 resolution: wont fix stage: resolved |
| 2012年06月18日 18:19:31 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg163111 |
| 2012年06月18日 17:40:47 | petri.lehtinen | set | nosy:
+ petri.lehtinen messages: + msg163109 |
| 2009年11月20日 01:34:56 | pitrou | set | nosy:
+ akuchling |
| 2009年11月19日 17:18:28 | pitrou | set | messages: + msg95496 |
| 2009年11月19日 17:06:45 | pitrou | set | messages: + msg95494 |
| 2009年11月19日 16:52:18 | pitrou | set | nosy:
+ pitrou messages: + msg95491 |
| 2009年11月19日 16:20:41 | doko | set | files: + mailbox-race.py |
| 2009年11月19日 16:20:21 | doko | create | |