Edgewall Software

Ticket #6490 (closed defect: fixed)

Opened 12 months ago

Last modified 12 months ago

Error when trying to delete priority

Reported by: jason Owned by: osimons
Priority: high Milestone: 0.11
Component: ticket system Version: devel
Severity: major Keywords:
Cc: justin@…

Description

When trying to delete a priority via WebAdmin:

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/api.py", line 341, in send_error
    'text/html')
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/chrome.py", line 608, in render_template
    if not req.session or not int(req.session.get('accesskeys', 0)):
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/api.py", line 170, in __getattr__
    value = self.callbacks[name](self)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/main.py", line 255, in _get_session
    return Session(self.env, req)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/session.py", line 53, in __init__
    self.get_session(req.authname, authenticated=True)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/session.py", line 74, in get_session
    (sid, int(authenticated)))
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: current transaction is aborted, commands ignored until end of transaction block

Attachments

Change History

  Changed 12 months ago by cboos

  • keywords needinfo added
  • milestone set to 0.11.1

That backtrace is a secondary error while trying to send the error which occurred when deleting the priority. Any hint about what could have caused that first failure? No existing priority?

(I can't trigger an error)

follow-up: ↓ 3   Changed 12 months ago by justin@…

  • cc justin@… added

I fixed it by taking out these lines in trac/ticket/model.py:

cursor.execute("UPDATE enum set value=value-1 where "

"type=%s and value>%s", (self.type, self._old_value))

Now I can delete priorities. But I can't fix the ordering to start from 1, which goofs up the coloring, as has been discussed in other tickets. I am using r6322.

in reply to: ↑ 2 ; follow-up: ↓ 4   Changed 12 months ago by osimons

  • keywords needinfo removed
  • owner changed from cmlenz to osimons
  • component changed from webadmin to ticket system

Replying to justin@jetiprinters.com:

I fixed it by taking out these lines in trac/ticket/model.py: cursor.execute("UPDATE enum set value=value-1 where " "type=%s and value>%s", (self.type, self._old_value))

Oops. That seems to be my change at [6317] for #2876. Worked fine on my test, but apparently it isn't stable enough. I'll look into it within the next couple of hours.

Now I can delete priorities. But I can't fix the ordering to start from 1, which goofs up the coloring, as has been discussed in other tickets. I am using r6322.

No. I have no solution for the ordering other than to clean it using sql like you want it - or delete all priorities and recreate them. That should reset the order.

in reply to: ↑ 3 ; follow-up: ↓ 5   Changed 12 months ago by jason

No. I have no solution for the ordering other than to clean it using sql like you want it - or delete all priorities and recreate them. That should reset the order.

Right. If I delete and recreate all priorities, what happens to existing tickets?

in reply to: ↑ 4   Changed 12 months ago by osimons

Replying to jason:

Right. If I delete and recreate all priorities, what happens to existing tickets?

They are just stored as values equal to name in tickets and ticket history. There are no foreign keys, so deleting and recreating should be a harmless operation. Do make a backup though, just to be sure.

Replying to osimons:

Oops. That seems to be my change at [6317] for #2876. Worked fine on my test, but apparently it isn't stable enough. I'll look into it within the next couple of hours.

Changed to use existing API instead of making new SQL - SQL that was obviously wrong now that I notice field is stored as text... My mistake. Could you/someone try this patch:

  • trac/ticket/model.py

     
    371371        self.env.log.info('Deleting %s %s' % (self.type, self.name)) 
    372372        cursor.execute("DELETE FROM enum WHERE type=%s AND value=%s", 
    373373                       (self.type, self._old_value)) 
    374         cursor.execute("UPDATE enum set value=value-1 where " 
    375                        "type=%s and value>%s", (self.type, self._old_value)) 
     374        # Re-order any enums that have higher value than deleted (close gaps) 
     375        for enum in self.select(self.env): 
     376            try: 
     377                if int(enum.value) > int(self._old_value): 
     378                    enum.value = unicode(int(enum.value)-1) 
     379                    enum.update(db=db) 
     380            except ValueError: 
     381                pass # Ignore cast error for this non-essential operation 
    376382 
    377383        if handle_ta: 
    378384            db.commit() 

I am quite sure that is a good working solution, but wouldn't mind confirmation.

  Changed 12 months ago by sid

#6494 was marked as duplicate of this ticket.

follow-up: ↓ 8   Changed 12 months ago by osimons

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 0.11.1 to 0.11

Patch (with comments from cmlenz) applied as [6323]. Sorry for the inconvenience - hope this does it :-)

in reply to: ↑ 7   Changed 12 months ago by jason

Replying to osimons:

Patch (with comments from cmlenz) applied as [6323]. Sorry for the inconvenience - hope this does it :-)

Seems OK now. And deleting / recreating all prioroties fixed up the ordering and ticket coloring.

Add/Change #6490 (Error when trying to delete priority)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from osimons. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.