BUG: Conflict competing write causes loss of form input
If you create new object in a form action, and the form action takes noticable time to finish, this bug may appear if two person is submitting the form simutaneously. One of the persons may lose his form input. These steps can reproduce this bug: 1. Make a temporary folder. 2. In the temporary folder, add an external method: import time def addFile(self, name, content): time.sleep(3) # this simulate a long action if hasattr(self, name): self.manage_delObjects([name]) self.manage_addDocument(name, name, content) 3. Add a DTML method/document named test_conflict with the following HTML form: <html><body> <form method="post" enctype="multipart/form-data" action="test_conflict_action"> name : <input name="name" value="tmpf1"><br> Content: <input name="content" value="This is tmpf1"><br> <input type="hidden" name="processing_form" value="1"> <br> <input type="submit" value="ADD File"> </form> </body></html> 4. Add a DTML method test_conflict_action: <html><body> <dtml-if processing_form> <dtml-var "REQUEST.form"> <dtml-call "addFile(name, content)"> <dtml-else> <em>Warning: Input lost</em> </dtml-if> </body></html> 5. Open two browser windows and view the "test_conflict" document. In the first browser window, input name as "tmpf1", in the second browser window, input name as "tmpf2. 6. Click the two submit buttons quickly. 7. The first browser window gives expected correct result: {'processing_form': '1', 'name': 'tmpf1', 'content': 'This is tmpf1'} but the second browser window will give the warning: input lost message: The server console will give the message: ------ 1999-12-05T11:02:45 INFO(0) Z2 CONFLICT Competing writes at, /Stat/TestBed/test_conflict_action Possible cause: When the two form action run simutaneously, a write conflict will occur because Zope use a transaction system. But the loss of the form input is not expected. In addition to the loss of form input bug, any suggestion on a work around of the conflict competing write problem? Can I avoid the conflict?
"Li Dongfeng (RA of H. Wong)" wrote:
If you create new object in a form action, and the form action takes noticable time to finish, this bug may appear if two person is submitting the form simutaneously. One of the persons may lose his form input.
These steps can reproduce this bug:
(snip excellent research)
In addition to the loss of form input bug, any suggestion on a work around of the conflict competing write problem?
I just checked in a fix for this. I neglected to reset the request body (a file-like object) when retrying the request. The fix entailed adding: self.stdin.seek(0) to the start of the HTTPRequest.retry method in lib/python/ZPublisher/HTTPRequest.py. Thanks for reporting this. Nice research. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (2)
-
Jim Fulton -
Li Dongfeng (RA of H. Wong)