davidkempers / django-tasks

Automatically exported from code.google.com/p/django-tasks
0 stars 0 forks source link

Scheduler tries the execute one task all the time #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install MySQL and Django
2. Run Djangotask
3. Add some task to the scheduler

What is the expected output? What do you see instead?
The Scheduler executed just one task.

See log:
I added a print statement to djangotasks/models.py:282
 # ... Then start any new task
        tasks = self.filter(status="scheduled",
                            archived=False)
        print tasks
        for task in tasks:

INFO:djangotasks:Starting task 18...
INFO:djangotasks:...Task 18 started.
INFO:djangotasks:Task 18 finished with status "successful"
[<Task: 18 - video.9.create_bittorrent>] 
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
INFO:djangotasks:Starting task 18...
INFO:djangotasks:...Task 18 started.
WARNING:djangotasks:Failed to change status from "scheduled" to "running" for 
task 18
[<Task: 18 - video.9.create_bittorrent>] 
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
INFO:djangotasks:Starting task 18...
INFO:djangotasks:...Task 18 started.
WARNING:djangotasks:Failed to change status from "scheduled" to "running" for 
task 18
[<Task: 18 - video.9.create_bittorrent>]
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
WARNING:djangotasks:A task on model=videoportal.video exists in the database, 
but is not defined in the code
[..every 5 sec]

As you can see the scheduler thinks the task has stil the status "scheduled"  
allthough it was succesfully processed before. The scheduler gets the status 
before the transaction in djangotasks/models.py:288.

tasks = self.filter(status="scheduled",
                            archived=False)

What version of the product are you using? On what operating system?
mysqld --version
mysqld  Ver 5.5.28-0ubuntu0.12.04.3 for debian-linux-gnu on x86_64 ((Ubuntu))
python --version
Python 2.7.3
django-tasks from
https://github.com/Piratenfraktion-Berlin/djangotasks

Please provide any additional information below.
The issue is related to Mysql and Django: 
http://stackoverflow.com/questions/3346124/how-do-i-force-django-to-ignore-any-c
aches-and-reload-data

adding the READ COMMITED Isolation to the DATABASES OPTIONS solves the issue

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
        'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", }
   }
}

Original issue reported on code.google.com by huhe...@googlemail.com on 11 Jan 2013 at 2:00