Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #280 (closed defect: duplicate)

Opened 14 years ago

Last modified 12 years ago

tg-admin sql create with new TurboTunes model.py fails.

Reported by: florian Owned by: anonymous
Priority: normal Milestone: 0.8
Component: SQLObject Version: 0.9a6
Severity: normal Keywords: sql postgres hang
Cc: pacopablo@…

Description

The most recent TurboTunes model.py using a postgres 8.0.4 database on turbotunes r391 and sqlobject 7.0 on a debian does the following upon tg-admin sql create:

  • It prints the db-connection string.
  • Prints this exceptions forever: Exception exceptions.RuntimeError?: 'maximum recursion depth exceeded' in <bound method Transaction.del of <sqlobject.dbconnection.Transaction object at 0x40a499ac>> ignored

I also observed under different circumstance that it would simply hang up, and when I interrupt there'd be a CREATE TABLE postgres process in wait mode that would not go away.

I can only observe this behavior since

Genre.createTable(ifNotExists=True)
Artist.createTable(ifNotExists=True)
Album.createTable(ifNotExists=True)
Song.createTable(ifNotExists=True)

was added on the TurboTunes model.py

Change History

comment:1 Changed 13 years ago by pacopablo

  • Cc pacopablo@… added

I am experiencing similar behavior. It prints the db connection string, but that's it. I am not seeing the exception

This is with:

The (very verbose) PostgreSQL log is:

Mar  1 22:41:43 [postgres] [1-1] LOG:  statement: SET DATESTYLE TO 'ISO'
Mar  1 22:41:43 [postgres] [2-1] LOG:  statement: BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
Mar  1 22:41:43 [postgres] [3-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [3-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [3-3] _            WHERE relname = 'genre'
Mar  1 22:41:43 [postgres] [3-4] _
Mar  1 22:41:43 [postgres] [4-1] LOG:  statement: CREATE TABLE genre (
Mar  1 22:41:43 [postgres] [4-2] _    id SERIAL PRIMARY KEY,
Mar  1 22:41:43 [postgres] [4-3] _    name VARCHAR(200)
Mar  1 22:41:43 [postgres] [4-4] _)
Mar  1 22:41:43 [postgres] [5-1] NOTICE:  CREATE TABLE will create implicit sequence "genre_id_seq" for serial column "genre.id"
Mar  1 22:41:43 [postgres] [6-1] NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "genre_pkey" for table "genre"
Mar  1 22:41:43 [postgres] [7-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [7-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [7-3] _            WHERE relname = 'artist'
Mar  1 22:41:43 [postgres] [7-4] _
Mar  1 22:41:43 [postgres] [8-1] LOG:  statement: CREATE TABLE artist (
Mar  1 22:41:43 [postgres] [8-2] _    id SERIAL PRIMARY KEY,
Mar  1 22:41:43 [postgres] [8-3] _    name VARCHAR(200)
Mar  1 22:41:43 [postgres] [8-4] _)
Mar  1 22:41:43 [postgres] [9-1] NOTICE:  CREATE TABLE will create implicit sequence "artist_id_seq" for serial column "artist.id"
Mar  1 22:41:43 [postgres] [10-1] NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "artist_pkey" for table "artist"
Mar  1 22:41:43 [postgres] [11-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [11-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [11-3] _            WHERE relname = 'artist_genre'
Mar  1 22:41:43 [postgres] [11-4] _
Mar  1 22:41:43 [postgres] [12-1] LOG:  statement: CREATE TABLE artist_genre (
Mar  1 22:41:43 [postgres] [12-2] _artist_id INT NOT NULL,
Mar  1 22:41:43 [postgres] [12-3] _genre_id INT NOT NULL
Mar  1 22:41:43 [postgres] [12-4] _)
Mar  1 22:41:43 [postgres] [13-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [13-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [13-3] _            WHERE relname = 'album'
Mar  1 22:41:43 [postgres] [13-4] _
Mar  1 22:41:43 [postgres] [14-1] LOG:  statement: CREATE TABLE album (
Mar  1 22:41:43 [postgres] [14-2] _    id SERIAL PRIMARY KEY,
Mar  1 22:41:43 [postgres] [14-3] _    name VARCHAR(200),
Mar  1 22:41:43 [postgres] [14-4] _    artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id)
Mar  1 22:41:43 [postgres] [14-5] _)
Mar  1 22:41:43 [postgres] [15-1] NOTICE:  CREATE TABLE will create implicit sequence "album_id_seq" for serial column "album.id"
Mar  1 22:41:43 [postgres] [16-1] NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "album_pkey" for table "album"
Mar  1 22:41:43 [postgres] [17-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [17-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [17-3] _            WHERE relname = 'song'
Mar  1 22:41:43 [postgres] [17-4] _
Mar  1 22:41:43 [postgres] [18-1] LOG:  statement: CREATE TABLE song (
Mar  1 22:41:43 [postgres] [18-2] _    id SERIAL PRIMARY KEY,
Mar  1 22:41:43 [postgres] [18-3] _    name VARCHAR(200),
Mar  1 22:41:43 [postgres] [18-4] _    album_id INT, CONSTRAINT album_id_exists FOREIGN KEY (album_id) REFERENCES album (id)
Mar  1 22:41:43 [postgres] [18-5] _)
Mar  1 22:41:43 [postgres] [19-1] NOTICE:  CREATE TABLE will create implicit sequence "song_id_seq" for serial column "song.id"
Mar  1 22:41:43 [postgres] [20-1] NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "song_pkey" for table "song"
Mar  1 22:41:43 [postgres] [1-1] LOG:  statement: SET DATESTYLE TO 'ISO'
Mar  1 22:41:43 [postgres] [2-1] LOG:  statement:
Mar  1 22:41:43 [postgres] [2-2] _            SELECT COUNT(relname) FROM pg_class
Mar  1 22:41:43 [postgres] [2-3] _            WHERE relname = 'album'
Mar  1 22:41:43 [postgres] [2-4] _
Mar  1 22:41:43 [postgres] [3-1] LOG:  statement: CREATE TABLE album (
Mar  1 22:41:43 [postgres] [3-2] _    id SERIAL PRIMARY KEY,
Mar  1 22:41:43 [postgres] [3-3] _    name VARCHAR(200),
Mar  1 22:41:43 [postgres] [3-4] _    artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id)
Mar  1 22:41:43 [postgres] [3-5] _)
Mar  1 22:41:43 [postgres] [4-1] NOTICE:  CREATE TABLE will create implicit sequence "album_id_seq" for serial column "album.id"

comment:2 Changed 13 years ago by pacopablo

FWIW, this only seems to be an issue with the TurboTunes model.py The 20 minute wiki works fine.

If I remove the following lines from model.py:

Genre.createTable(ifNotExists=True)
Artist.createTable(ifNotExists=True)
Album.createTable(ifNotExists=True)
Song.createTable(ifNotExists=True)

then I get the following error when trying to run tg-admin sql create

Traceback (most recent call last):
  File "/usr/bin/tg-admin", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a1dev_r882-py2.4.egg/turbogears/command/base.py", line 270, in main
    command.run()
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a1dev_r882-py2.4.egg/turbogears/command/base.py", line 129, in run
    command.the_runner.run(sys.argv)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/manager/command.py", line 102, in run
    runner.run()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/manager/command.py", line 233, in run
    self.command()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/manager/command.py", line 569, in command
    soClass.createTable()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/main.py", line 1322, in createTable
    conn.createTable(cls)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/dbconnection.py", line 524, in createTable
    self.query(self.createTableSQL(soClass))
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/dbconnection.py", line 305, in query
    return self._runWithConnection(self._query, s)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/dbconnection.py", line 219, in _runWithConnection
    val = meth(conn, *args)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/dbconnection.py", line 302, in _query
    self._executeRetry(conn, conn.cursor(), s)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1632-py2.4.egg/sqlobject/dbconnection.py", line 297, in _executeRetry
    return cursor.execute(query)
psycopg.ProgrammingError: ERROR:  relation "artist" does not exist

CREATE TABLE album (
    id SERIAL PRIMARY KEY,
    name VARCHAR(200),
    artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id) 
)

comment:3 Changed 13 years ago by anonymous

debugging a little more, it seems that it's the ForeignKey?('Artist') in the Album class that is causing the psycopg.ProgrammingError.

I changed the model so that all columns were StringCol. With the .createTable statements left in, the tg-admin sql create command hung. Taking out those lines, the database was created successfully.

I then restored the MultipleJoin, RelatedJoin and ForeignKey cols one at a time until it borked again on ForeignKey('Artist').

Here are more logs:

LOG:  statement: SET DATESTYLE TO 'ISO'
LOG:  statement: SHOW client_encoding
LOG:  statement: SHOW default_transaction_isolation
LOG:  statement: BEGIN; SET TRANSACTION ISOLATION LEVEL READ COMMITTED
LOG:  statement: SELECT COUNT(relname) FROM pg_class WHERE relname = 'artist'
LOG:  statement: CREATE TABLE artist (
            id SERIAL PRIMARY KEY,
            name VARCHAR(200)
        )
NOTICE:  CREATE TABLE will create implicit sequence "artist_id_seq" for serial column "artist.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "artist_pkey" for table "artist"
LOG:  statement: SELECT COUNT(relname) FROM pg_class WHERE relname = 'artist_genre'
LOG:  statement: CREATE TABLE artist_genre (
        artist_id INT NOT NULL,
        genre_id INT NOT NULL
        )
LOG:  statement: SET DATESTYLE TO 'ISO'
LOG:  statement: SHOW client_encoding
LOG:  statement: SHOW default_transaction_isolation
LOG:  statement: BEGIN; SET TRANSACTION ISOLATION LEVEL READ COMMITTED
LOG:  statement: SELECT COUNT(relname) FROM pg_class WHERE relname = 'album'
LOG:  statement: END
LOG:  statement: BEGIN; SET TRANSACTION ISOLATION LEVEL READ COMMITTED
LOG:  statement: CREATE TABLE album (
            id SERIAL PRIMARY KEY,
            name VARCHAR(200),
            artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id)
        )
NOTICE:  CREATE TABLE will create implicit sequence "album_id_seq" for serial column "album.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "album_pkey" for table "album"
ERROR:  relation "artist" does not exist
LOG:  statement: END
LOG:  statement: ABORT
LOG:  unexpected EOF on client connection

To my untrained eye, it looks as though the FOREIGN KEY statement should work as the artist table appears to be created.

So, I hope someone can figure this out, cus I'm at the end of my time and abilities.

I'll note too that I tried using the latest SQLObject dev egg

easy_install SQLObject==dev

And that didn't fix anything.

comment:4 Changed 13 years ago by anonymous

Same symptoms here, under Windows, with the following versions:

  • Python2.4
  • TurboGears-0.9a1dev_r937
  • SQLObject-0.7.1dev_r1457
  • psycopg2-2.0b8.win32

In the turbotunes tutorial, tg-admin sql create just hangs there after printing:

Using database URI postgres://postgres:password@localhost/turbotunes

Without the createTable(ifNotExists=True) calls, I get the error:

psycopg.ProgrammingError: ERROR:  relation "artist" does not exist

Any ideas about this one?

comment:5 Changed 13 years ago by anonymous

Found a solution in ticket #279: replace all the createTable(ifNotExists=True) statements by this single line:

soClasses = ('Artist', 'Album', 'Genre', 'Song')

comment:6 Changed 13 years ago by godoy

  • Status changed from new to closed
  • Resolution set to duplicate

This is a duplicate of #279. I'm closing it as well.

Note: See TracTickets for help on using tickets.