Edgewall Software

Ticket #3948 (reopened defect)

Opened 2 years ago

Last modified 6 months ago

Can't add a new report

Reported by: anonymous Owned by: mgood
Priority: normal Milestone: 0.10.6
Component: report system Version: 0.10
Severity: minor Keywords: postgresql upgrade
Cc: johngluck@…, chris+trac@…

Description (last modified by cboos) (diff)

I get this when I save a new report

Python Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 356, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 224, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.4/site-packages/trac/ticket/report.py", line 79, in process_request
    self._do_create(req, db)
  File "/usr/local/lib/python2.4/site-packages/trac/ticket/report.py", line 128, in _do_create
    "VALUES (%s,%s,%s)", (title, query, description))
  File "/usr/local/lib/python2.4/site-packages/trac/db/util.py", line 47, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/local/lib/python2.4/site-packages/trac/db/util.py", line 47, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 3111, in execute
    raise OperationalError, msg
OperationalError: ERROR:  duplicate key violates unique constraint "report_pkey"

Attachments

Change History

  Changed 2 years ago by anonymous

I've already updated my system from 0.9 to 0.10. With version 0.9 this feature worked great.

follow-up: ↓ 5   Changed 2 years ago by anonymous

  • status changed from new to closed
  • resolution set to fixed

Solved adding one manually to the database. May be during the update process from .9 to .10 some counter didn't update properly

follow-up: ↓ 4   Changed 2 years ago by cboos

  • status changed from closed to reopened
  • resolution fixed deleted
  • description modified (diff)

(wrong resolution type, fixed should be used only for issues requiring code changes)

Did you also switch from SQLite to PostgreSQL at the same time?

in reply to: ↑ 3   Changed 2 years ago by mgood

  • status changed from reopened to closed
  • resolution set to worksforme

Replying to cboos:

(wrong resolution type, fixed should be used only for issues requiring code changes)

I assume you meant to change the resolution to worksforme.

in reply to: ↑ 2   Changed 23 months ago by anonymous

Replying to anonymous:

Solved adding one manually to the database. May be during the update process from .9 to .10 some counter didn't update properly

PostgreSQL7 has this problem after initial instance creation. Something with serial id field, I believe.

For those who want to to that, exact sql queries (add report and then remove it):

INSERT INTO report (title,query,description)
  VALUES ('one more test report', 'select 3*3', 'ZZZ')

DELETE FROM report
  WHERE query = 'select 3*3' and description = 'ZZZ'

  Changed 22 months ago by mikef@…

  • status changed from closed to reopened
  • resolution worksforme deleted

The migration is _broken_ from 0.9 to 0.10 with Postgres. I had to manually set the sequence to the right value.

  Changed 21 months ago by cboos

  • keywords postgresql upgrade added
  • priority changed from high to normal
  • severity changed from normal to minor
  • milestone set to 0.10.5

I don't think this is ever going to be fixed, but it could be documented.

  Changed 15 months ago by anonymous

  • cc chris+trac@… added

How can it be worked around?

  Changed 14 months ago by anonymous

Yes, how can this be worked around. Please leave instructions?

  Changed 14 months ago by anonymous

  • cc johngluck@… added; chris+trac@… removed

Please tell us how to work around this problem

  Changed 14 months ago by anonymous

  • cc chris+trac@… added

please don't remove me from the CC:

  Changed 13 months ago by tankcatninjafish@…

This is what I did to fix for postgresql 8.1 and trac 10.4 (which I upgraded from .9.something). Background info: Auto incrementing Primary keys in postgresql tables have a counter which you can manually view and modify. So the reports table has a counter 'report_id_seq'::regclass

\d report;
                            Table "public.report"
   Column    |  Type   |                      Modifiers
-------------+---------+-----------------------------------------------------
 id          | integer | not null default nextval('report_id_seq'::regclass)
 author      | text    |
 title       | text    |
 query       | text    |
 description | text    |

To see the current counter value, do:

select currval('report_id_seq'::regclass);
 currval
---------
       8
(1 row)

8 is definitely wrong because I have around 30 or so reports. So I'll reset it to something high like 40:

select setval('report_id_seq'::regclass,40);
 setval
--------
     40
(1 row)

And the next report should be added correctly with and ID of 41 (which is 40 + 1 because the counter gets incremented). Hopes this helps some unlucky soul.

  Changed 6 months ago by ischenko@…

I can confirm the problem on Trac 0.11rc1. It seems that either counter is not updated or Trac doesn't see refreshed value. After I used setval to update id I tried to create yet another report and it used previously used id. So basically I have to setval each time I need a report defined.

Add/Change #3948 (Can't add a new report)

Author



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