Saturday, October 25, 2014

Re: migrate and runserver commands hang, there is no traceback, no clue yet why (1.7.1)

Carl,

Thanks for responding and giving your input. I just made sure there were no other terminals with any sort of connection open. At times I have pgAdmin III open but that is currently closed and I ran migrate and same thing it hangs. The only other terminals I have are one terminal sitting after the server is closed down for my other project and another that has a live email server open in python.

jjs-macbook-pro:~ JJZ$ python -m smtpd -n -c DebuggingServer localhost:1025

which I don't think would cause an issue and just to check I used control c to close it down and tried to migrate but again it hangs there.

As you can see so far I'm in a pretty big bind, I wish I had any sort of lead on this issue. Feel free to ask me for any other code etc or do any sort of method or operation to hopefully shed more light on this. 

Thanks a lot,

JJ



On Saturday, October 25, 2014 5:15:04 PM UTC-4, Carl Meyer wrote:
Hi JJ,

One thing that can cause hangs when running migrations is having another process (say a 'manage.py shell') with a connection to the same database sitting open, possibly with a transaction in progress that is holding locks on the tables the migrations need to touch. Any possibility that's what happened here?

Carl

On Oct 25, 2014, at 2:23 PM, JJ Zolper <jzt...@gmail.com> wrote:

I really wish I could give some useful information in the terms of a traceback so others may have an idea what is happening to me but I'm completely serious when I say I don't even get a traceback right now. Here is the break down of what I did to give an idea of how I ended up at this point, hopefully. I will continue to try to iterate upon this discussion as well through observations to try to work on my own or with others to get down to the cause of the issue.

First with a clean and empty database I ran the migrate command and everything went fine. There were no issues as it ran through:

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py migrate

Operations to perform:

  Synchronize unmigrated apps: colleges, ads, debug_toolbar, comments, communities, main, athletes, ad_manager

  Apply all migrations: admin, contenttypes, sites, auth, sessions

Synchronizing apps without migrations:

  Creating tables...

    Creating table athletes_athlete_athletecolleges

    Creating table athletes_athlete_athletecommunities

    Creating table athletes_athlete

    Creating table athletes_registrationprofile

    Creating table colleges_college

    Creating table colleges_collegeevent_attendees

    Creating table colleges_collegeevent

    Creating table communities_community

    Creating table communities_country

    Creating table communities_city

    Creating table communities_communitypost_city

    Creating table communities_communitypost_country

    Creating table communities_communitypost

    Creating table comments

    Creating table comment_flags

    Creating table main_teammember

    Creating table ads_partner

    Creating table ads_ad

    Creating table ad_manager_target

    Creating table ad_manager_adgroup

    Creating table ad_manager_ad

    Creating table ad_manager_pagetype

    Creating table ad_manager_adtype

    Creating table ad_manager_tagtype

  Installing custom SQL...

  Installing indexes...

Running migrations:

  Applying contenttypes.0001_initial... OK

  Applying auth.0001_initial... OK

  Applying admin.0001_initial... OK

  Applying sessions.0001_initial... OK

  Applying sites.0001_initial... OK


Next up I called to create a super user and that went fine as well:

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py createsuperuser

Username (leave blank to use 'jjz'): 

Email address: 

Password: 

Password (again): 


Superuser created successfully.


Then I ran the makemigrations command for the respective apps and their models that I wanted to have:

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations colleges

Migrations for 'colleges':

  0001_initial.py:

    - Create model College

    - Create model CollegeEvent

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations ads

Migrations for 'ads':

  0001_initial.py:

    - Create model Ad

    - Create model Partner

    - Add field partner to ad

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations comments

Migrations for 'comments':

  0001_initial.py:

    - Create model Comment

    - Create model CommentFlag

    - Alter unique_together for commentflag (1 constraint(s))

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations communities

Migrations for 'communities':

  0001_initial.py:

    - Create model City

    - Create model Community

    - Create model CommunityPost

    - Create model Country

    - Add field country to communitypost

    - Add field user to communitypost

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations main

Migrations for 'main':

  0001_initial.py:

    - Create model TeamMember

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations athletes

Migrations for 'athletes':

  0001_initial.py:

    - Create model Athlete


    - Create model RegistrationProfile


Up until this point I had no concerns, things seemed to be working as expected, but what happened next stunned me. The migrate command hung it just sat there seemingly doing nothing. I hit command c to cancel because I'm on a mac thinking maybe I had done something wrong and it wouldn't happen again but it continues.

I tried to run runserver next:

(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py runserver

Performing system checks...


System check identified no issues (0 silenced).

^C(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py migrate


^C


As you can see it hung and I had to cancel and hit command c on both runserver and the following migrate.

Sorry for the wall of text but I just want to put this all out there in case it gives any awareness. Anyways, here is my speculation to what is causing the "endless loop" within my models, I say this because I didn't have this issue up until I started messing with this part of my models. Here is one of those models (because it has the user FK):

# College Event

class CollegeEvent(models.Model):

    collegeid = models.CharField(max_length=30)

    user = models.ForeignKey('athletes.Athlete', verbose_name=_('user'), blank=True, null=True, related_name="%(class)s_events")

    creatorname = models.CharField(max_length=30)

    creatorurl = models.CharField(max_length=30)

    ispublished = models.BooleanField(default=False)

    name = models.CharField(max_length=30)

    description = models.TextField()

    startdate = models.CharField(max_length=30)

    enddate = models.CharField(max_length=30)

    attendees = models.ManyToManyField(settings.AUTH_USER_MODEL, null=True, blank=True)

    objects = models.Manager()

    ceobjects = CollegeEventManager()

    

    def __unicode__(self):

        return self.name


    def get_creator_full_name(self):


        return self.user.first_name + " " + self.user.last_name


The key line being:

    user = models.ForeignKey('athletes.Athlete', verbose_name=_('user'), blank=True, null=True, related_name="%(class)s_events")

I thought maybe it couldn't migrate this because of the FK to Athlete, even though I used this declaration before my understanding is it includes that model in the FK. I tried importing the the athlete model from the database above this definition but there was still no output or change in the issue. What I'm saying is before this line is the way it is above I had a foreignkey to settings.AUTH_USER_MODEL. But the funny thing is I actually had that definition commented out in my settings.py. The reason being I thought I needed to go that route originally with my Athlete django users but then realized I would just use a one to one field to a django user. Thus why I changed it to 'athletes.Athlete'.

# Athlete User

class Athlete(models.Model):

    athleteuser = models.OneToOneField(User)

    athleteavatar = models.ImageField("Profile Pic", upload_to="images/", blank=True, null=True, default='images/None/no-img.jpeg')

    athletebirthday = models.DateField()

    athleteurl = models.CharField(max_length=30, unique=True)              # Must limit to a-z && A-Z && and 0-9 chars, validators=[validate_slug]

    athletecommunities = models.ManyToManyField('communities.Community')

    athletecolleges = models.ManyToManyField('colleges.College')


I wish I could give more information but I simply can't think of anything else right now that could be relevant. It's funny because I saw this:

  • Modified migrations dependency algorithm to avoid possible infinite recursion.

on the new release notes:


and it honestly seems to sound exactly like that. It seems like some sort of infinite recursion or something similar it can't get out of it. It can't identify the issue it gets thrown through and so it sits there endlessly.

And yes again I am using 1.7.1, I just updated the other day.

Thanks a lot,

JJ Zolper




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd5c0b56-44fd-436f-b957-ad2cbfcd63a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a90fcfdf-221d-4cca-9b07-fdca095fb5dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment