First time here? Check out the FAQ!
0

Errors while trying to rename or delete unused tags

Hi,

As listed here: http://askbot.org/en/question/2673/is-there-a-way-to-purge-unused-tags-from-the-db/ , I tried to run the tag commands. I'm not sure if it works. It seems to error out:

[root@ask01.stg config]# python manage.py delete_unused_tags
/usr/lib/python2.6/site-packages/django/db/__init__.py:19: DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead.
  DeprecationWarning
/usr/lib/python2.6/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
  DeprecationWarning
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 "manage.py", line 10, in <module>
    execute_manager(settings)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 222, in inner
    self.__exit__(None, None, None)
  File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 207, in __exit__
    self.exiting(exc_value, self.using)
  File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 302, in exiting
    leave_transaction_management(using=using)
  File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 56, in leave_transaction_management
    connection.leave_transaction_management()
  File "/usr/lib/python2.6/site-packages/django/db/backends/__init__.py", 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.

Update:

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

http://stackoverflow.com/questions/5647675/transaction-managed-block-ended-with-pending-commit-rollback

http://stackoverflow.com/questions/9955321/django-transaction-managed-block-ended-with-pending-commit-rollback

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

FranciscoD's avatar
71
FranciscoD
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

Comments

add a comment see more comments

1 Answer

2

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
260
powlo
answered 2013-08-21 11:16:45 -0500
edit flag offensive 0 remove flag delete link

Comments

1

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
1

https://github.com/ASKBOT/askbot-devel/pull/160

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