First time here? Check out the FAQ!

Errors while trying to rename or delete unused tags


As listed here: , I tried to run the tag commands. I'm not sure if it works. It seems to error out:

[root@ask01.stg config]# python delete_unused_tags
/usr/lib/python2.6/site-packages/django/db/ DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead.
/usr/lib/python2.6/site-packages/django/db/ DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
WARNING!!! You are using a 'locmem' (local memory) caching backend,
which is OK for a low volume site running on a single-process server.
For a multi-process configuration it is neccessary to have a production
cache system, such as redis or memcached.

With local memory caching and multi-process setup you might intermittently
see outdated content on your site.

Searching for unused tags:
------------------------------------------------------------ 100.00%
Did not find any.
Traceback (most recent call last):
  File "", line 10, in <module>
  File "/usr/lib/python2.6/site-packages/django/core/management/", line 438, in execute_manager
  File "/usr/lib/python2.6/site-packages/django/core/management/", line 379, in execute
  File "/usr/lib/python2.6/site-packages/django/core/management/", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/django/db/", line 222, in inner
    self.__exit__(None, None, None)
  File "/usr/lib/python2.6/site-packages/django/db/", line 207, in __exit__
    self.exiting(exc_value, self.using)
  File "/usr/lib/python2.6/site-packages/django/db/", line 302, in exiting
  File "/usr/lib/python2.6/site-packages/django/db/", line 56, in leave_transaction_management
  File "/usr/lib/python2.6/site-packages/django/db/backends/", line 115, in leave_transaction_management
    raise TransactionManagementError("Transaction managed block ended with "
django.db.transaction.TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

Is this working? It said it didn't find any unused tags but still spews the trace back. A similar error is spewed while using the other tag commands too.


I've googled and the error seems to be quite common:

Does this happen on I'm running this without switching off the website.

FranciscoD's avatar
asked 2013-07-12 01:02:30 -0500, updated 2013-08-09 01:04:18 -0500
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

1 Answer


Firstly, this command only deletes tags whose Questions have been deleted, ie removed from the database. If the Question has been marked deleted (ie not visible to users but still visible to administrators in the backend interface) then tags pointing to this question are still valid, so the tag will not be deleted.

So that's possibly why you see the "Did not find any" message.

That being said, the way the database transactions are handled could be improved. I'll submit a patch.

I was able to recreate the problem by having no tags in the db. However, it may also occur under other circumstances, eg if some exception occurs during command execution.

powlo's avatar
answered 2013-08-21 11:16:45 -0500
edit flag offensive 0 remove flag delete link



Great. I'll be happy to test the patch out on our staging instance once you've written it. We don't delete questions from the backend. Should we? It would be nice to stop these tags from showing up in the suggestions etc. The idea is to direct users to use a standard set of tags rather than use random tags. Thanks.

FranciscoD's avatar FranciscoD (2013-08-21 23:11:47 -0500) edit

I can't really comment on whether you should delete questions. Maybe if your database is too big?

ETA: It sounds like you need a feature to disable user created tags. Is that right?

powlo's avatar powlo (2013-08-23 13:29:55 -0500) edit

Thanks. I'll see if I can test that pull out on our staging instance. We don't want to completely disable user creation of tags. Maybe put a karma requirement? The idea is to control the tag set really. The problem on askfedora is that users have already gone ahead and created quite random tags. Since these aren't deleted yet for the reason you state, they are still showed as options in the tag chooser box which makes more users use them. I manually retag a lot of questions but until the non-standard tags are permanently removed (not shown as suggestions), new users will keep using them.

FranciscoD's avatar FranciscoD (2013-08-23 21:14:08 -0500) edit

So, a karma requirement for creation of new tags, and a way to keep certain tags from showing in suggestions (delete them permanently?) might do the trick. Thanks again.

FranciscoD's avatar FranciscoD (2013-08-23 21:15:35 -0500) edit
add a comment see more comments