[Zope] BUG: Conflict competing write causes loss of form input

Li Dongfeng (RA of H. Wong) mavip5@inet.polyu.edu.hk
Sun, 05 Dec 1999 19:08:58 +0800


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?