TransactionManagementError attempting to create product variation from configurable product

Create issue
Issue #643 resolved
Former user created an issue

From what I understand, this is an impossible scenario, but users should get a proper error message instead of a 500.

{{{ Environment: Request Method: POST Request URL: http://mysite.com/admin/product/productvariation/add/ Django Version: 1.0-final-SVN-unknown Python Version: 2.5.1 Installed Applications: ['django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.comments', 'django.contrib.markup', 'comment_utils', 'django.contrib.sitemaps', 'satchmo.caching', 'satchmo.configuration', 'satchmo.shop', 'satchmo.contact', 'satchmo.product', 'satchmo.shipping', 'satchmo.payment', 'satchmo.discount', 'satchmo.giftcertificate', 'satchmo.supplier', 'satchmo.thumbnail', 'sorl.thumbnail', 'satchmo.l10n', 'satchmo.tax', 'satchmo.recentlist', 'satchmo.productratings', 'mysite.cos_tags'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'satchmo.shop.SSLMiddleware.SSLRedirect', 'satchmo.recentlist.middleware.RecentProductMiddleware') Traceback: File "/django/virtualenv/mysite.com/lib/python2.5/site-packages/django/core/hand lers/base.py" in get_response 86. response = callback(request, callback_args, *callback_kwargs) Exception Type: TransactionManagementError at /admin/product/productvariation/add/ Exception Value: Transaction managed block ended with pending COMMIT/ROLLBACK

And here is the postgresql log:

2008-11-18 16:48:12 MST ERROR: insert or update on table "product_productvariation_options" violates foreign key constraint "product_productvariation_options_productvariation_id_fkey" 2008-11-18 16:48:12 MST DETAIL: Key (productvariation_id)=(1) is not present in table "product_productvariation". 2008-11-18 16:48:12 MST STATEMENT: END 2008-11-18 16:48:12 MST WARNING: there is no transaction in progress }}}

Reported by baumer1122

Comments (2)

  1. Antti Kaihola

    I just hit this issue. I did a clean installation of Satchmo, created a couple of categories and products, a configurable product, an option group and three option items for the group. As a newbie, I didn't first understand that product variations should be created via the configurable product page and tried to create product variations manually. After filling in all fields, I got the following:

    Environment:
    
    Request Method: POST
    Request URL: http://localhost:8000/admin/product/productvariation/add/
    Django Version: 1.1 pre-alpha
    Python Version: 2.5.2
    Installed Applications:
    ['satchmo_store.shop',
     'django.contrib.admin',
     'django.contrib.admindocs',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.comments',
     'django.contrib.sessions',
     'django.contrib.sitemaps',
     'django.contrib.sites',
     'sorl.thumbnail',
     'satchmo',
     'keyedcache',
     'livesettings',
     'satchmo_store.contact',
     'product',
     'shipping',
     'payment',
     'satchmo_store.contact.supplier',
     'satchmo_utils',
     'satchmo_utils.thumbnail',
     'l10n',
     'tax',
     'app_plugins']
    Installed Middleware:
    ('django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.locale.LocaleMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.middleware.doc.XViewMiddleware',
     'threaded_multihost.middleware.ThreadLocalMiddleware',
     'satchmo_store.shop.SSLMiddleware.SSLRedirect',
     'satchmo_ext.recentlist.middleware.RecentProductMiddleware')
    
    
    Traceback:
    File "django/core/handlers/base.py" in get_response
      86.                 response = callback(request, *callback_args, **callback_kwargs)
    File "django/contrib/admin/sites.py" in root
      450.                 return self.model_page(request, *url.split('/', 2))
    File "django/views/decorators/cache.py" in _wrapped_view_func
      44.         response = view_func(request, *args, **kwargs)
    File "django/contrib/admin/sites.py" in model_page
      469.         return admin_obj(request, rest_of_url)
    File "django/contrib/admin/options.py" in __call__
      795.             return self.add_view(request)
    File "django/db/transaction.py" in _commit_on_success
      249.             leave_transaction_management()
    File "django/db/transaction.py" in leave_transaction_management
      75.         raise TransactionManagementError(
                      "Transaction managed block ended with pending COMMIT/ROLLBACK")
    
    Exception Type: TransactionManagementError at /admin/product/productvariation/add/
    Exception Value: Transaction managed block ended with pending COMMIT/ROLLBACK
    

    My PostgreSQL 8.3 log:

    2009-01-30 18:21:17 EET ERROR:
      insert or update on table "product_productvariation_options" violates
      foreign key constraint "product_productvariation_options_productvariation_id_fkey"
    2009-01-30 18:21:17 EET DETAIL:
      Key (productvariation_id)=(1) is not present in table "product_productvariation".
    2009-01-30 18:21:17 EET STATEMENT:  COMMIT
    

    I'm running [django9781] and Satchmo [1923].

  2. Hynek Cernoch

    Transaction management has changed in django-livesettings r13:756c27d5a535, which is the most probable cause. The changeset 7615da7b0d9c has fixed issue an issue #1285 last time. Other transaction related Satchmo code I have checked. Also transaction management in Django has changed. In January 2009 it did not exist release Satchmo 1923, the highest was 864. I think, the bug is not even not relevant but not possible to be reproduced, what exactly fixed it.

  3. Log in to comment