Edgewall Software
Modify

Ticket #8658 (closed defect: duplicate)

Opened 2 years ago

Last modified 15 months ago

AttributeError: 'ResourceSystem' object has no attribute '_resource_managers_map'

Reported by: cboos Owned by: cboos
Priority: low Milestone:
Component: general Version: 0.11-stable
Severity: major Keywords: componentmanager
Cc: felix.schwarz@…
Release Notes:
API Changes:

Description

How to Reproduce

While issuing a bunch of concurrent requests, I got the following traceback:

Traceback (most recent call last):
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\web\main.py", line 445, in _dispatch_request
    dispatcher.dispatch(req)
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\web\main.py", line 206, in dispatch
    resp = chosen_handler.process_request(req)
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\wiki\web_ui.py", line 166, in process_request
    return self._render_view(req, versioned_page)
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\wiki\web_ui.py", line 489, in _render_view
    req.href, format=conversion[0])
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\resource.py", line 291, in get_resource_url
    manager = ResourceSystem(env).get_resource_manager(resource.realm)
  File "C:\Workspace\src\trac\repos\0.11-stable\trac\resource.py", line 238, in get_resource_manager
    if not self._resource_managers_map:
AttributeError: 'ResourceSystem' object has no attribute '_resource_managers_map'

I already had similar failures in other testing sessions, and this amounts to a race condition in the ComponentManager, in source:trunk/trac/core.py, which can lead to methods of the component being called before the __init__ method itself has been called.

The fix is not trivial, I somehow stopped working on it, but I think it's worth recording the problem anyway and eventually fix it one day.

Well, actually there is a trivial fix, which would be to set variables like _resource_managers_map at the class level, which would avoid the internal error, but this ticket is more about solving the problem of __init__ not being guaranteed to be called before other methods can be called.

Typical "low prio" but "high severity" kind of ticket, as this leads to an internal error but fortunately happens only once in a blue moon...

Attachments

t8658-Component-init.diff (1.1 KB) - added by cboos 20 months ago.
core: prevent possible use of uninitialized Component. Patch on top of r9839

Download all attachments as: .zip

Change History

comment:1 Changed 22 months ago by cboos

  • Milestone changed from 2.0 to unscheduled

Milestone 2.0 deleted

Changed 20 months ago by cboos

core: prevent possible use of uninitialized Component. Patch on top of r9839

comment:2 Changed 20 months ago by cboos

  • Milestone changed from triaging to 0.12.1
  • Status changed from new to assigned

As discussed in #9418, we can trade the above problem for an (increased) chance to get multiple instances created, which is certainly less damaging most of the time. At worst, these extra instances will result in caches created for a one time use.

Last edited 17 months ago by cboos (previous) (diff)

comment:3 Changed 17 months ago by cboos

  • Milestone changed from 0.12.1 to 0.13

Still, I wouldn't touch that in 0.12-stable, now.

comment:4 Changed 16 months ago by fschwarz

  • Cc felix.schwarz@… added

comment:5 follow-up: Changed 16 months ago by cboos

  • Milestone changed from 0.13 to 0.12.2

t8658-Component-init.diff applied in r10242.

Thanks to Felix Schwarz for reviving the issue and for independent rediscovery of the fix ;-)

comment:6 Changed 16 months ago by cboos

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:7 in reply to: ↑ 5 Changed 16 months ago by fschwarz

Replying to cboos:

t8658-Component-init.diff applied in r10242.

Thanks for applying this so quickly. However I had quite a lot of fallout for Agilo due to that. Granted, Agilo is one of the most complex 'plugins' for Trac and I identified quite a lot of bad design decisions during that plugin but I guess the change might break other plugins as well.

Therefore I'd like to propose that the change is only done in trunk but not for 0.12 stable to minimize potential issues in the stable series.

comment:8 Changed 16 months ago by cboos

  • Resolution fixed deleted
  • Status changed from closed to reopened

On trunk I'd rather go the way proposed in #9418 anyway. Did you have a chance to review and test the proposed change?

As for r10242, I would be OK to revert it on 0.12-stable.

comment:9 Changed 15 months ago by cboos

  • Resolution set to duplicate
  • Status changed from reopened to closed

r10242 reverted in r10292, also on trunk to make way for jomae's patch on #9418.

comment:10 Changed 15 months ago by cboos

  • Milestone 0.12.2 deleted
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from cboos. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.