<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 5/28/13 7:53 PM, Dylan Jay wrote:<br>
</div>
<blockquote
cite="mid:F55F0ACC-86F4-4303-969B-6427A29A3941@pretaweb.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div apple-content-edited="true">Hi,
</div>
<div apple-content-edited="true"><br>
</div>
<div apple-content-edited="true">My colleague is having the issue
outlined below. I thought this list might be better to give an
insight as to what is going on?</div>
<div><br>
<div>Begin forwarded message:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="margin-top: 0px; margin-right: 0px; margin-bottom:
0px; margin-left: 0px;"><span
style="font-family:'Helvetica'; font-size:medium;
color:rgba(0, 0, 0, 1.0);"><b>From: </b></span><span
style="font-family:'Helvetica'; font-size:medium;">Adam
Terrey <<a moz-do-not-send="true"
href="mailto:adam@pretaweb.com">adam@pretaweb.com</a>><br>
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom:
0px; margin-left: 0px;"><span
style="font-family:'Helvetica'; font-size:medium;
color:rgba(0, 0, 0, 1.0);"><b>Subject: </b></span><span
style="font-family:'Helvetica'; font-size:medium;"><b>Fwd:
Zope/Plone/Zeo Concurrency Issue</b><br>
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom:
0px; margin-left: 0px;"><span
style="font-family:'Helvetica'; font-size:medium;
color:rgba(0, 0, 0, 1.0);"><b>Date: </b></span><span
style="font-family:'Helvetica'; font-size:medium;">28 May
2013 5:23:33 PM AEST<br>
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom:
0px; margin-left: 0px;"><span
style="font-family:'Helvetica'; font-size:medium;
color:rgba(0, 0, 0, 1.0);"><b>To: </b></span><span
style="font-family:'Helvetica'; font-size:medium;">Dylan
Jay <<a moz-do-not-send="true"
href="mailto:djay@pretaweb.com">djay@pretaweb.com</a>><br>
</span></div>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<div bgcolor="#FFFFFF" text="#000000"> <br>
<div class="moz-forward-container"><br>
<br>
-------- Original Message --------
<table class="moz-email-headers-table" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
</th>
<td>Zope/Plone/Zeo Concurrency Issue</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date:
</th>
<td>Tue, 28 May 2013 16:04:21 +1000</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">From:
</th>
<td>Adam Terrey <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:adam@pretaweb.com"><adam@pretaweb.com></a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">To:
</th>
<td><a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:Zope@zope.org">Zope@zope.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi,<br>
<br>
Can someone offer some insight into what might be going on
here and perhaps how I can debug the following issue?<br>
<br>
In Plone there is a request patten used to create content
which looks like...<br>
<ul>
<li>(A) GET request to
/MySite/createObject?type_name=Document<br>
Responds with a redirect to a tempory document at a
location such as
/MySite/portal_factory/Document/document.2013-05-28.1878040976/edit</li>
<li>(B) GET
/MySite/portal_factory/Document/document.2013-05-28.1878040976/edit<br>
Responds with from to set fields in the Document<br>
</li>
<li>(C) POST request to
/MySite/portal_factory/Document/document.2013-05-28.1878040976/atct_edit<br>
Responds with a redirect to the final location of the
document such as /Mysite/my-page</li>
<li>(D) GET /Mysite/my-page<br>
Responds with the newly created page<br>
</li>
</ul>
<p>In one of our production systems we are running
multiple Zope/Plone instances connecting to a Zeo
server. And the above patten works about 95% of the
time. However, sometimes request (D) will respond with
404 Page Not Found. My assumptions is that request (C)
and (D) are going to different instances and somehow the
instance handling request (D) does not yet see the
transaction with completed the page creation.<br>
</p>
I've checked that the transaction commit happens before
response headers are emitted for request (C) - suspecting
the case that the browser handles the redirect before the
transaction is completed - but this is clearly not the
case from what i can see. The transaction is well
committed before response headers are returned.<br>
<br>
Versions are as follows:<br>
<ul>
<li>Plone 4.1.3 (4112)</li>
<li>CMF 2.2.4</li>
<li>Zope 2.13.10</li>
<li>Python 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC
4.6.1]</li>
</ul>
I have been using the following script to recreate the
issue. I seem to be able to produce the error quicker if I
put server2 under apache-bench load, and I have been able
to recreate the issue on a local copy of our production
system but it is a far more rare case.<br>
<br>
auth = ('admin', 'admin')<br>
server1 = '<a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://localhost:46101/">http://localhost:46101</a>'<br>
server2 = '<a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://localhost:46102/">http://localhost:46102</a>'<br>
site = '/Plone'<br>
<br>
import requests<br>
<br>
ses = requests.Session()<br>
ses.auth=auth<br>
<br>
for i in range(10):<br>
<br>
# Create tempory Object<br>
create_url = server1 + site +
'/createObject?type_name=Document'<br>
print "GET", create_url<br>
res = ses.get (create_url)<br>
tempory_obj = res.url.rsplit("/", 1)[0]<br>
print "tempory object:", tempory_obj<br>
<br>
<br>
# Submit data to create object (response will<br>
# be the redirect ot the ojbect's location)<br>
<br>
data = {<br>
'id': '',<br>
'title': 'page' + str(i) ,<br>
'form.button.save': 'Save',<br>
'form.submitted': '1',<br>
"description": "some secriot",<br>
"text": "some text"<br>
}<br>
<br>
post_url = tempory_obj + "/atct_edit" <br>
print "POST", post_url<br>
res = ses.post(post_url, data=data,
allow_redirects=False)<br>
<br>
redirect_location = "/" +
res.headers['location'][7:].split('/',1)[1]<br>
print 'redirect_location', redirect_location<br>
<br>
<br>
# Request object from the redirect from server2<br>
redirect_url = server2 + redirect_location<br>
print "GET", redirect_url <br>
res = ses.get(redirect_url)<br>
<br>
if res.status_code != 200:<br>
last404 = res<br>
print res;<br>
break;<br>
<br>
print "---"<br>
<br>
<br>
Any help would be appreciated.<br>
<br>
</div>
</div>
</blockquote>
</div>
</blockquote>
<br>
I've encountered a problem like this once or twice and had some
trouble reproducing it consistently, but assume it's due to ZEO
invalidation messages not making it to the other instance before it
serves request D.<br>
<br>
You can work around the issue using sticky sessions in your load
balancer. If you don't want users to be stuck to a particular
backend indefinitely you can set a cookie with a brief expiration in
an ObjectAddedEvent handler and use it as the basis for the
stickiness.<br>
<br>
</body>
</html>