Modify

Opened 8 weeks ago

Last modified 7 weeks ago

#14360 accepted defect

TicketTagProvider fetching `tags` records before the `tags` table created

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Component: TagsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.6

Description

This behavior leads trac:#13804.

17:43:29 Trac[env] ERROR: Component <Component tracspamfilter.filters.trapfield.TrapFieldFilterStrategy> failed with
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/trac/env.py", line 382, in component_guard
    yield
  File "/usr/local/lib/python3.13/site-packages/trac/env.py", line 750, in needs_upgrade
    if participant.environment_needs_upgrade():
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tracspamfilter/filters/trapfield.py", line 116, in environment_needs_upgrade
    chrome.load_template(os.devnull)  # to set chrome.jenv property
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/web/chrome.py", line 1316, in load_template
    jinja2_dirs = self.get_all_templates_dirs()
  File "/usr/local/lib/python3.13/site-packages/trac/web/chrome.py", line 772, in get_all_templates_dirs
    for provider in self.template_providers:
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 96, in extensions
    components = [component.compmgr[cls] for cls in classes]
                  ~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 238, in __getitem__
    component = cls(self)
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 158, in __call__
    self.__init__()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tractags/wiki.py", line 101, in __init__
    self.tag_system = TagSystem(self.env)
                      ~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 158, in __call__
    self.__init__()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tractags/api.py", line 249, in __init__
    self._populate_provider_map()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tractags/api.py", line 465, in _populate_provider_map
    for provider in self.tag_providers)
                    ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 96, in extensions
    components = [component.compmgr[cls] for cls in classes]
                  ~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 238, in __getitem__
    component = cls(self)
  File "/usr/local/lib/python3.13/site-packages/trac/core.py", line 158, in __call__
    self.__init__()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tractags/ticket.py", line 53, in __init__
    self._fetch_tkt_tags()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tractags/ticket.py", line 215, in _fetch_tkt_tags
    rw_cursor.execute("""
    ~~~~~~~~~~~~~~~~~^^^^
        DELETE FROM tags
        ^^^^^^^^^^^^^^^^
    ...<3 lines>...
        """ % (db.cast('tags.name', 'int'), ignore),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        (self.realm,))
        ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/trac/db/util.py", line 73, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: relation "tags" does not exist
LINE 2:                 DELETE FROM tags
                                    ^
UndefinedTable: relation "tags" does not exist
LINE 2:                 DELETE FROM tags
                                    ^

Error: Unable to check for upgrade of tracspamfilter.filters.trapfield.TrapFieldFilterStrategy: UndefinedTable: relation "tags" does not exist
LINE 2:                 DELETE FROM tags
                                    ^

Attachments (0)

Change History (2)

comment:1 Changed 7 weeks ago by Jun Omae

In 18665:

TracTags: use @lazy decorator to avoid fetching records on component initiation as a workaround (refs #14360)

comment:2 Changed 7 weeks ago by Jun Omae

Owner: changed from Ryan J Ollos to Jun Omae
Status: newaccepted

Currently, the tags table is refreshed on each TicketTagProvider initiation. It leads performance issues by many tickets and/or concurrent requests. I think we should provide tags sync command to refresh tags table instead of refreshing on requests.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as accepted The owner will remain Jun Omae.

Add Comment


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

 
Note: See TracTickets for help on using tickets.