[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 13:35:13 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3989c10aaba5b81b9cb45109428a36a66fadedb0
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 20 23:59:13 2010 +0000

    2010-09-20  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            The commit-cluster bots still race to lock patch_ids
            https://bugs.webkit.org/show_bug.cgi?id=46130
    
            It turns out we need to use a transaction object to make the
            read/modify/write lock operation atomic.  From reading the AppEngine
            documentation, I think this patch should do what we want.  It's hard to
            test locally because the test instance isn't distributed in the same
            way the production instance is.
    
            * QueueStatusServer/handlers/nextpatch.py:
            * QueueStatusServer/model/activeworkitems.py: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67893 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 202402a..91c0636 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,19 @@
+2010-09-20  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        The commit-cluster bots still race to lock patch_ids
+        https://bugs.webkit.org/show_bug.cgi?id=46130
+
+        It turns out we need to use a transaction object to make the
+        read/modify/write lock operation atomic.  From reading the AppEngine
+        documentation, I think this patch should do what we want.  It's hard to
+        test locally because the test instance isn't distributed in the same
+        way the production instance is.
+
+        * QueueStatusServer/handlers/nextpatch.py:
+        * QueueStatusServer/model/activeworkitems.py: Added.
+
 2010-09-20  Andy Estes  <aestes at apple.com>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/QueueStatusServer/handlers/nextpatch.py b/WebKitTools/QueueStatusServer/handlers/nextpatch.py
index 45be8bb..edb702a 100644
--- a/WebKitTools/QueueStatusServer/handlers/nextpatch.py
+++ b/WebKitTools/QueueStatusServer/handlers/nextpatch.py
@@ -26,9 +26,11 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from google.appengine.ext import db
 from google.appengine.ext import webapp
 
 from model.workitems import WorkItems
+from model.activeworkitems import ActiveWorkItems
 from model import queuestatus
 
 from datetime import datetime, timedelta
@@ -39,26 +41,21 @@ class NextPatch(webapp.RequestHandler):
         work_items = WorkItems.all().filter("queue_name =", queue_name).get()
         if not work_items:
             return None
-        one_hour_ago = datetime.now() - timedelta(minutes=60)
-        statuses = queuestatus.QueueStatus.all().filter("queue_name =", queue_name).filter("date >", one_hour_ago).fetch(15)
-        active_patch_ids = set([status.active_patch_id for status in statuses])
-        for item_id in work_items.item_ids:
-            if item_id not in active_patch_ids:
-                return item_id
-        # Either there were no work items, or they're all active.
-        return None
-
-    def _assign(self, queue_name, patch_id):
-        queue_status = queuestatus.QueueStatus()
-        queue_status.queue_name = queue_name
-        queue_status.active_patch_id = patch_id
-        queue_status.message = "Assigned for processing"
-        queue_status.put()
+        active_work_items = ActiveWorkItems.get_or_insert(key_name=queue_name, queue_name=queue_name)
+        return db.run_in_transaction(self._assign_patch, active_work_items.key(), work_items.item_ids)
 
     def get(self, queue_name):
         patch_id = self._get_next_patch_id(queue_name)
         if not patch_id:
             self.error(404)
             return
-        self._assign(queue_name, patch_id)
         self.response.out.write(patch_id)
+
+    @staticmethod
+    def _assign_patch(key, work_item_ids):
+        now = datetime.now()
+        active_work_items = db.get(key)
+        active_work_items.deactivate_expired(now)
+        next_item = active_work_items.next_item(work_item_ids, now)
+        active_work_items.put()
+        return next_item
diff --git a/WebKitTools/QueueStatusServer/model/activeworkitems.py b/WebKitTools/QueueStatusServer/model/activeworkitems.py
new file mode 100644
index 0000000..e24e6ca
--- /dev/null
+++ b/WebKitTools/QueueStatusServer/model/activeworkitems.py
@@ -0,0 +1,58 @@
+# Copyright (C) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from google.appengine.ext import db
+
+from datetime import timedelta
+import time
+
+
+class ActiveWorkItems(db.Model):
+    queue_name = db.StringProperty()
+    item_ids = db.ListProperty(int)
+    item_dates = db.ListProperty(float)
+    date = db.DateTimeProperty(auto_now_add=True)
+
+    def deactivate_expired(self, now):
+        one_hour_ago = time.mktime((now - timedelta(minutes=60)).timetuple())
+        nonexpired_item_ids = []
+        nonexpired_item_dates = []
+        for i in range(len(self.item_ids)):
+            if self.item_dates[i] > one_hour_ago:
+                nonexpired_item_ids.append(self.item_ids[i])
+                nonexpired_item_dates.append(self.item_dates[i])
+        self.item_ids = nonexpired_item_ids
+        self.item_dates = nonexpired_item_dates
+
+    def next_item(self, work_item_ids, now):
+        for item_id in work_item_ids:
+            if item_id not in self.item_ids:
+                self.item_ids.append(item_id)
+                self.item_dates.append(time.mktime(now.timetuple()))
+                return item_id
+        return None

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list