Add a random chance to ignore a job to reduce contention
This should probably be solved better (perhaps with a binary
exponential backoff).
Patch by: Sverre Rabbelier
--- a/app/soc/views/models/cron.py Sun Apr 19 00:06:46 2009 +0000
+++ b/app/soc/views/models/cron.py Sun Apr 19 00:07:05 2009 +0000
@@ -22,6 +22,8 @@
]
+import random
+
from django import http
from soc.logic import dicts
@@ -91,6 +93,8 @@
jobs = job_logic.entityIterator(queryGen, batchSize=10)
for job in jobs:
+ if random.randint(0, 5) > 0:
+ continue
job_key = job.key().id()
good = handler.handle(job_key)