[issue1599254] mailbox: other programs' messages can vanish without trace

Jim Jewett report at bugs.python.org
Wed Mar 19 02:20:48 CET 2014


Jim Jewett added the comment:

OK, if I understand *that* correctly,

(1)  The locking mechanism doesn't really work, and that is too complicated to fix in this issue.  A new issue would be fine.

(2)  The locking failure messes up the Table Of Contents, but that is too comprehensive a change to fix here, and should be handled in the new issue.

(3)  The locking failure also causes data loss/corruption in the messages themselves, and that *can* be fixed simply by truncate+append, instead of renaming.  (Is this actually true, or only true if you *also* implement better change-detection to catch the other process?)

(4)  While the patches do (and test for) #3, there is not currently a patch that *only* does #3.

(5)  This is a pure bug fix; the only reason to change documentation would be to help make triggering the bugs less likely.

===

Also note that

(6)  At least some of the changes do seem to have been included at some point, so regenerating the patches is not mechanical.

(7)  The documentation has a big warning note, but the wording could use some improvement to emphasize that *even* reading is unsafe, if changes (even status changes, such as a "Seen" flag) could happen later.  Again, based on my possibly faulty understanding:

"If you’re modifying a mailbox, you must lock it by calling the lock() and unlock() methods before reading any messages in the file or making any changes"

-->

"Keys may become invalid at any time, unless the mailbox is locked. 

Notably, another process may modify the underlying file storage so that the key used to retrieve an existing message becomes invalid, or points to a different message.  To prevent this, a mailbox must be locked prior to even reading a message, and must not be unlocked until all changes -- even status changes, such as whether or not a Message was viewed -- for all keys have been completed and flushed."

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1599254>
_______________________________________


More information about the Python-bugs-list mailing list