title: Celerybeat schedule executing task multiple times?
body: <p>I have a task <em>calculate_common_locations</em> which runs once via <code>CELERYBEAT_SCHEDULE</code>.
  The task simply calls a function in the database:</p>
  
  <pre><code>@app.task
  def calculate_common_locations():
      db.execute("SELECT * FROM calculate_centroids('b')")
  </code></pre>
  
  <p>This is the entry in <code>CELERYBEAT_SCHEDULE</code>:</p>
  
  <pre><code>CELERYBEAT_SCHEDULE = {
     'common_locations': {
          'task': 'clients.tasks.calculate_common_locations',
          'schedule': crontab(hour=23, day_of_week='sun'), #every week
      },
      [..]
  }
  </code></pre>
  
  <p>The schedule includes more tasks that run <em>once a day</em> or <em>every 10 seconds</em>. These tasks seem to be not re-run many times.
  Celery flower shows the task is executed more than 20 times.
  The first one started as scheduled, runs ~100s, succeeds and then starts again.</p>
  
  <p><img src="https://i.stack.imgur.com/ZZmQA.png" alt="enter image description here"></p>
  
  <p>There is only one celerybeat running:</p>
  
  <pre><code>ps -Af | grep celerybeat 
  foo     24359   779  0 01:53 ?        00:00:04 [celeryd: celery@celery:MainProcess] -active- (worker --beat --app=cloud.celeryapp:app --concurrency=10 -l INFO -s /home/foo/run/celerybeat-schedule --pidfile=/home/foo/run/celerybeat.pid)         
  </code></pre>
  
  <p>This is how celery gets started (via supervisord):</p>
  
  <pre><code>celery worker --beat --app=cloud.celery app:app --concurrency=10 -l INFO -s /home/foo/run/celerybeat-schedule --pidfile=/home/foo/run/celerybeat.pid
  </code></pre>
  
  <p>I have tested it without the <em>--concurrency=10</em> switch. The database function is still executed multiple times.</p>
  
  <p>The function reads from a large table (> 1 Mil rows) that is inserted into quite often (a couple of times a second). Postgres locks show that all locks are granted.</p>
  
  <p>Is it possible that the task is being re-run because the query terminates at some point?</p>
  
  <p><strong>There is no issues when:</strong></p>
  
  <ul>
  <li>the task is run from the django shell (directly or via <code>.delay()</code>),</li>
  <li>the task's content is replaced by a lightweight sql query (select * from test),</li>
  <li>the task's content is replaced by a <em>sleep(100)</em>.</li>
  </ul>
  
  <p>Versions:</p>
  
  <ul>
  <li><strong>celery==3.1.12</strong></li>
  <li><strong>psql (PostgreSQL) 9.3.5</strong></li>
  </ul>