Modify

Opened 18 months ago

Closed 18 months ago

Last modified 16 months ago

#11000 closed defect (fixed)

Leaking resources by incorrect use of `open_environment`

Reported by: jun66j5 Owned by: k0s
Priority: normal Component: TicketMoverPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

Original issue at trac:#11139.

The following error is caused by incorrect use of open_environment.

OSError: [Errno 24] Too many open files: '/opt/trac'

open_environment without use_cache creates every time a new instance of Environment. However, TicketMoverPlugin doesn't release nor cache. Therefore, some resources leak.

  • ticketmoverplugin/ticketmover.py

     
    155155        for project in _projects: 
    156156            path = os.path.join(base_path, project) 
    157157            try: 
    158                 env = open_environment(path) 
     158                env = open_environment(path, use_cache=True) 
    159159            except: 
    160160                continue 
    161161            perm = PermissionSystem(env) 
     
    176176        # open the environment if it is a string 
    177177        if isinstance(env, basestring): 
    178178            base_path, _project = os.path.split(self.env.path) 
    179             env = open_environment(os.path.join(base_path, env)) 
     179            env = open_environment(os.path.join(base_path, env), use_cache=True) 
    180180 
    181181        # get the old ticket 
    182182        old_ticket = Ticket(self.env, ticket_id) 

Attachments (0)

Change History (4)

comment:1 Changed 18 months ago by rjollos

jun66j5: k0s is no longer active in the Trac community and has given permission for his plugins to be adopted, so feel free to push the patch directly to the repository.

comment:2 Changed 18 months ago by jun66j5

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

(In [12863]) TicketMoverPlugin: fix #11000: leaking resources caused by open_environment

comment:3 Changed 16 months ago by rjollos

jun66j5: #11091 reports a significant slowdown when using this plugin. We aren't sure yet which version is being used, but do you think the issue you fixed here could be the cause?

comment:4 Changed 16 months ago by jun66j5

Yes. I think that the slowdown in #11091 has been fixed by [12863].

Before the changes, Trac constructs all tracenvs using open_environment on every request while viewing ticket page. After the changes, Trac uses Environment instances in the cache.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.