Modify

Opened 8 years ago

Closed 7 years ago

#12831 closed defect (fixed)

Plugin giving DB error when trying to launch certain pages

Reported by: daniel@… Owned by: Franz
Priority: high Component: BudgetingPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

How to Reproduce

While doing a GET operation on /newticket, Trac issued an internal error.

Installed the plugin using easy_install. Installs AOK with no errors. Activate the plugin AOK and trac.ini has appropriate fields entered.

Upon trying to access New Ticket or to view a ticket the follow error occurs. Any help would be much appreciated.

Request parameters:

{}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

System Information

Trac 0.12.5
Genshi 0.6 (with speedups)
Mercurial 2.2.2
mod_wsgi 3.3 (WSGIProcessGroup wsgitrac WSGIApplicationGroup 127.0.1.1|)
Pygments 1.5
pysqlite 2.6.0
Python 2.7.3 (default, Jun 21 2016, 18:50:31)
[GCC 4.7.2]
pytz 2012c
setuptools 0.6
SQLite 3.7.13
Subversion 1.6.17 (r1128011)
jQuery 1.11.2

Enabled Plugins

BatchModify 0.8.1-trac0.12dev-r11791
BlueFlatTheme 1.0
BreadCrumbsNav 0.2-r10896
Budgeting-Plugin 0.5.a4
ComponentHierarchy 0.0.1dev-r14642
HttpHostLink N/A
IniAdmin 0.3-r13607
milncheckbox N/A
PrivateWikis 1.0.0
Roadmap-Plugin 0.4.1
SimpleMultiProject 0.5.2dev
ticket-clone N/A
TicketImport 0.8.3
TracAccess 0.1
TracAccountManager 0.4.4
Tracchildtickets 1.2.0.BETA
TracCustomFieldAdmin 0.2.12
TracDynamicFields 2.2.0dev
TracForms 0.4.1-r10490
TracGanttCalendarPlugin 0.6.4
TracMercurial 0.12.0.28
TracPrivateTickets 2.1.0dev-r13943
TracSQL 0.3
TracThemeEngine 2.0.1
TracWysiwyg 0.12.0.5-r13457

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 522, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 264, in dispatch
    content_type)
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 844, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 132, in __or__
    return Stream(_ensure(function(self)), serializer=self.serializer)
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 1000, in inner
    data)
  File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 287, in filter_stream
    self.create_table()
  File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 759, in create_table
    self.create_reports()
  File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 782, in create_reports
    raise e
OperationalError: near ".": syntax error

Attachments (2)

t12831.diff (1.9 KB) - added by Ryan J Ollos 8 years ago.
t12831-2.diff (8.7 KB) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 8 years ago by Ryan J Ollos

The exception should be logged: budgetingplugin/0.12/ticketbudgeting/ticketbudgeting.py@10991:765,780#L761. Look for a line [INIT reports] Error executing SQL Statement .... Note also line 765 in which a read-only DB connection is obtained, but an INSERT statement is executed. That looks like a problem. It appears the issue doesn't exist on trunk, but you'll need to be running Trac 1.0 or later to use that version: budgetingplugin/trunk/ticketbudgeting/ticketbudgeting.py@14669#L733.

Changed 8 years ago by Ryan J Ollos

Attachment: t12831.diff added

comment:2 Changed 8 years ago by Ryan J Ollos

Could you please test patch t12831.diff against the latest budgetingplugin/0.12?

comment:3 Changed 8 years ago by anonymous

Sorry for the slow reply rjollos, just returned to the office. Thanks for your help and suggestions so far but we still seem to be having the same issues:

File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 522, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 264, in dispatch
  content_type)
File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 844, in render_template
  stream |= self._filter_stream(req, method, filename, stream, data)
File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 132, in __or__
  return Stream(_ensure(function(self)), serializer=self.serializer)
File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 1000, in inner
  data)
File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 287, in filter_stream
  self.create_table()
File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 758, in create_table
  self.create_reports()
File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 781, in create_reports
  raise e

Also, there was an issue with the Patch itself in that there were two Non-ASCII characters one on line 239 and the other online 271, both of which caused the patch to not work in the first instance.

Any further suggestions would be much appreciated

All the best,

Dan

Last edited 8 years ago by Jun Omae (previous) (diff)

Changed 8 years ago by Jun Omae

Attachment: t12831-2.diff added

comment:4 in reply to:  3 Changed 8 years ago by Jun Omae

Replying to anonymous:

File "/usr/local/lib/python2.7/dist-packages/Budgeting_Plugin-0.5.a4-py2.7.egg/ticketbudgeting/ticketbudgeting.py", line 781, in create_reports
  raise e

We should use raise rather than raise e because stacktrace of the exception would be lost.

Also, there was an issue with the Patch itself in that there were two Non-ASCII characters one on line 239 and the other online 271, both of which caused the patch to not work in the first instance.

That is caused by no encoding comment in ticketbudgeting.py.

This plugin has many issues:

  • In create_reports(), must use parameter passing.
  • In create_table(), ignoring an exception while creating table.
  • FLOOR() and TRUE doesn't work with SQLite.

Could you please try t12831-2.diff against the latest budgetingplugin/0.12?

comment:5 Changed 8 years ago by anonymous

Hi jun66j5,

Thanks for the patch it appears to have fixed the initial errors and I can now load the new ticket & ticket pages AOK. However, on entering data using the plugin fields, nothing appears to be saving into the DB table "budgeting" (I checked this using the SQL viewer plugin). Therefore when the page refreshes after saving, nothing has been saved or loaded back onto the ticket.

I have checked the logs and there are no errors coming through.

Any help is much appreciated.

All the best,

Dan

comment:6 Changed 8 years ago by Jun Omae

Works for me with default configuration. After the patch, budgeting record is created when submitting an new ticket with budget estimation.

The following is logged with TracLogging with DEBUG level and [trac] debug_sql = true:

02:59:39 PM Trac[util] DEBUG: SQL: u"insert into budgeting (ticket, position, comment,username,cost,status,estimation,type) values (3, 1, '#12831','None',40.0,0,42.0,'Implementation')"
02:59:39 PM Trac[util] DEBUG: prefetch: 0 rows
02:59:39 PM Trac[ticketbudgeting] DEBUG: saved budget of position: 1
02:59:39 PM Trac[util] DEBUG: SQL: u"INSERT INTO ticket_change(ticket, time, author, field, oldvalue, newvalue) VALUES(3, 1.47141357833e+15, 'admin', 'budgeting.1', '', 'None, Implementation: #12831')"
02:59:39 PM Trac[util] DEBUG: prefetch: 0 rows
02:59:39 PM Trac[ticketbudgeting] DEBUG: successfully logged budget, pos 1 for ticket 3
02:59:39 PM Trac[ticketbudgeting] DEBUG: have local ini, so everything is set

Could you please post trac.log when creating an new ticket with DEBUG level and enabling [trac] debug_sql option?

comment:7 Changed 8 years ago by Franz

My collegue and me orginally coded that plugin. The plugin was one of our first Trac plugins and our entry to Python. We also focused mainly to PostgreSQL, because that is the used database system in our Trac environment. That's the reason, why the plugin might be programmed not fully "pythonic" and as described in Trac's Styleguide.

Initializing, esp. creating table BUDGETING after installation, was a problem that I could not fixed eventually. As it worked in our environment, I left it as it is.

Unfortunately I have no time improving this plugin anymore. If you have any questions, please do not hesitate to contact me.

@Trac-Commiters (Jun, Ryan, etc.): please feel free to commit your patches.

comment:8 Changed 7 years ago by Ryan J Ollos

In 16149:

0.6.6dev: Fix SQL errors in report 90 with SQLite

Patch by Jun Omae. Refs #12831, Fixes #11211.

comment:9 Changed 7 years ago by Ryan J Ollos

In 16154:

0.6.6dev: Avoid KeyError with no locale directory

Patch by Jun Omae. Refs #12831.

comment:10 Changed 7 years ago by Ryan J Ollos

In 16155:

0.6.6dev: Conform to PEP8

Refs #12831.

comment:11 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

I think all the changes in attachment:t12831-2.diff have been committed, except table creation. I created #13013 for additional changes.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Franz.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.