Edgewall Software

Ticket #5135 (closed enhancement: duplicate)

Opened 17 months ago

Last modified 16 months ago

Config parse_if_needed() does not handle removing items with multiple processes

Reported by: simon-code@… Owned by: jonas
Priority: normal Milestone:
Component: general Version: 0.10.4
Severity: normal Keywords: config
Cc:

Description

I run Apache/mod_python, and multiple processes will therefore access, parse and update the environment config settings. For all 'normal' trac.ini settings this works fine - a change for project description, header logo or anything else where an option (or default) already exists. As expected - so far, so good.

I am writing an Admin plugin for creating, updating and deleting ticket custom fields. It works by adding the various config settings, config.save() and then as each process checks the file timestamp it will (hopefully) do a config.parse_if_needed() and reload settings so that each environment gets the new set of custom fields with correct information.

  • Creating works fine. The new options are read and added.
  • Updating works fine. Changing type of existing field, changing sort order, updating default values or options for select.
  • But; Deleting does not work well as it leads to totally random behaviour when reloading my admin page list of custom fields - it all depends on what process displays the page at a given time as they are out of sync.

Research led me to how the config is actually parsed - and especially when it is re-parsed through config.parse_if_needed(). This parser depends on each option having some sort of default value in that it is always able to update a field, but has no way of detecting an existing field in current config that should be completely removed - and no trace remaining. Options in 'ticket-custom' section in an environment configuration can only be removed (or reset) by actually restarting server.

So, I have prepared a patch (config-reparse-with-section-delete.diff). With the ongoing work of the new workflow that also is very dependent on trac.ini files for its behavior, I am sure this is of interest to more config sections than my immediate interest. The patch will completely clear out specific sections before parsing the updated file - ensuring that the current settings as defined in trac.ini will be used.

Attachments

config-reparse-with-section-delete.diff (1.0 kB) - added by simon-code@… 17 months ago.
Patch for removing specific sections before re-parsing config.

Change History

Changed 17 months ago by simon-code@…

Patch for removing specific sections before re-parsing config.

Changed 17 months ago by simon-code@…

  • keywords config added

Some of the discussions at #3037 is relevant to this issue - discussing how options should/could be 'removed' in various circumstances.

Changed 16 months ago by osimons <simon-code@…>

  • version changed from 0.10.3 to 0.10.4

I have added a patch to #3833 (ticket:3833:env_reload_5342.diff that solves this in a completely different manner - by reloading the environment in the env_cache instead. It is a much better and much more general solution to config updates.

I think my original patch to this ticket (config-reparse-with-section-delete.diff) is the wrong approach - it heads down a path that only serves to complicate, and for instance it will not solve it for other external plugins that adds arbitrary list of options that can be extended and retracted without any 'default' behavior defined using Config options.

Changed 16 months ago by cboos

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

Superseded by #3833 (and the above mentioned patch)

Add/Change #5135 (Config parse_if_needed() does not handle removing items with multiple processes)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.